pingouin.madmedianrule

pingouin.madmedianrule(a)[source]

Robust outlier detection based on the MAD-median rule.

Parameters
aarray-like

Input array. Must be one-dimensional.

Returns
outliers: boolean (same shape as a)

Boolean array indicating whether each sample is an outlier (True) or not (False).

Notes

The MAD-median-rule will refer to declaring \(X_i\) an outlier if

\[\frac{\left | X_i - M \right |}{\text{MAD}_{\text{norm}}} > K,\]

where \(M\) is the median of \(X\), \(\text{MAD}_{\text{norm}}\) the normalized median absolute deviation of \(X\) (see pingouin.mad()), and \(K\) is the square root of the .975 quantile of a \(X^2\) distribution with one degree of freedom, which is roughly equal to 2.24.

References

1

Hall, P., Welsh, A.H., 1985. Limit theorems for the median deviation. Ann. Inst. Stat. Math. 37, 27–36. https://doi.org/10.1007/BF02481078

2

Wilcox, R. R. Introduction to Robust Estimation and Hypothesis Testing. (Academic Press, 2011).

Examples

>>> import pingouin as pg
>>> a = [-1.09, 1., 0.28, -1.51, -0.58, 6.61, -2.43, -0.43]
>>> pg.madmedianrule(a)
array([False, False, False, False, False,  True, False, False])