MEDABSDEV Name
medabsdev
Purpose
This function returns a data set's median absolute deviation
from the median. That is, it returns
median( |data - median(data) | )
It is a proxy for the standard deviation, but is more resistent
against outliers. Category
Statistics
Calling Sequence
result = medabssdev(data, [/sigma], [/even])
Inputs
data: An array of data
Keyword Parameters
sigma: If set, divide the median absolute deviation by
inverseErf(0.5) * sqrt(2). This scales the MAD to an approximation
for sigma (assuming a Gaussian distribution)
median: On output, holds the median of the data
even: If set and data contains an even number of points,
medians are computed as the average of the two middle numbers.
The returned values may not be an element of the original data.
Outputs
median( |data - median(data)| )
Note
For the gaussian distribution,
medabsdev / sigma = inverseErf(0.5) * sqrt(2) = 0.67449
Examples
IDL> dist = randomn(seed, 50)
IDL> outlier = 1d7
IDL> data = [dist, outlier]
IDL> print, stdev(dist), stdev(data)
1.09757 1400280.1
IDL> print, medabsdev(dist), medabsdev(data)
0.597564 0.59756410
Modification History
Aug 2009: Written by Chris Beaumont
Sep 2009: Added /SIGMA keyword. cnb.
Oct 2009: Added input checking. cnb.
Oct 2010: Added median keyword. cnb.
Jul 2012: Added /even keyword. Julio Castro