Skip to content
Myr

Add MAD=0 unit tests for outlier detection, see #329

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by sharkdp · committed by sharkdp · parent 25f8129 · Browse files · 1 file+13 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−0 removed

  • other:+13 added−0 removed

1 file+13 added−0 removed

modified:src/hyperfine/outlier_detection.rs+13 added
27 unmodified lines
2829 // Compute median absolute deviation:30 let mad = median(&deviations);3132 // Handle MAD == 0 case33 let mad = if mad > 0.0 { mad } else { f64::EPSILON };3435 // Compute modified Z-scores (x_i - x_median) / MAD36 xs.iter().map(|&x| (x - x_median) / mad).collect()37}38
62 unmodified lines
101 -500.0,102 ];103 assert_eq!(2, num_outliers(&xs));104}105106#[test]107fn test_detect_outliers_if_mad_becomes_0() {108 // See https://stats.stackexchange.com/q/339932109 let xs = [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 100.0];110 assert_eq!(1, num_outliers(&xs));111112 let xs = [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 100.0, 100.0];113 assert_eq!(2, num_outliers(&xs));114}