Robust z-Scores with the MAD

easy
Unit 5 · Pandas & Outliers0/3 to milestone

The mean and standard deviation are themselves pulled by outliers. The modified z-score (Iglewicz & Hoaglin) uses the median and the median absolute deviation:

Mi=0.6745 (xi−x~)MAD,MAD=median(∣xi−x~∣)M_i = \frac{0.6745\,(x_i - \tilde x)}{\text{MAD}},\qquad \text{MAD} = \text{median}(|x_i - \tilde x|)

Implement modified_z(x) and robust_outliers(x, threshold=3.5) (flags ∣Mi∣>|M_i| > threshold). If MAD is 0, every point that differs from the median gets M=±∞M = \pm\infty and points equal to it get 0.

#outliers#robust-statistics2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Robust z-Scores with the MAD · TechGradify