median_absolute_deviation¶
-
astropy.stats.
median_absolute_deviation
(a, axis=None)[source] [edit on github]¶ Compute the median absolute deviation.
Returns the median absolute deviation (MAD) of the array elements. The MAD is defined as
median(abs(a - median(a)))
.Parameters: a : array-like
Input array or object that can be converted to an array.
axis : int, optional
Axis along which the medians are computed. The default (axis=None) is to compute the median along a flattened version of the array.
Returns: median_absolute_deviation : ndarray
A new array holding the result. If the input contains integers, or floats of smaller precision than 64, then the output data-type is float64. Otherwise, the output data-type is the same as that of the input.
See also
Examples
This will generate random variates from a Gaussian distribution and return the median absolute deviation for that distribution:
>>> from astropy.stats import median_absolute_deviation >>> from numpy.random import randn >>> randvar = randn(10000) >>> mad = median_absolute_deviation(randvar)