Module mad

Module mad 

Source
Expand description

anomaly_score_mad window function โ€” MAD-based anomaly scoring.

Algorithm: score = |x - median(window)| / (MAD * 1.4826) where MAD = median(|xi - median(window)|)

When MAD = 0 (majority-constant window), returns 0.0 if value equals median, or +inf otherwise.

Structsยง

AnomalyScoreMad
AnomalyScoreMadEvaluator ๐Ÿ”’

Constantsยง

MAD_CONSISTENCY_CONSTANT ๐Ÿ”’
MAD consistency constant for normal distribution: 1 / ฮฆโปยน(3/4) โ‰ˆ 1.4826
MIN_SAMPLES ๐Ÿ”’
Minimum valid samples for MAD (n <= 2 makes MAD almost always 0, yielding spurious +inf).