### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »

# spacepy.toolbox.medAbsDev

`spacepy.toolbox.``medAbsDev`(series)

  Calculate median absolute deviation of a given input series

  Median absolute deviation (MAD) is a robust and resistant measure of the spread of a sample (same purpose as standard deviation). The MAD is preferred to the inter-quartile range as the inter-quartile range only shows 50% of the data whereas the MAD uses all data but remains robust and resistant. See e.g. Wilks, Statistical methods for the Atmospheric Sciences, 1995, Ch. 3.

  Parameters: | series : array_like the input data series
  Returns: | out : float the median absolute deviation

  Examples

  Find the median absolute deviation of a data set. Here we use the log- normal distribution fitted to the population of sawtooth intervals, see Morley and Henderson, Comment, Geophysical Research Letters, 2009.

      >>> import numpy
      >>> import spacepy.toolbox as tb
      >>> numpy.random.seed(8675301)
      >>> data = numpy.random.lognormal(mean=5.1458, sigma=0.302313, size=30)
      >>> print data
      array([ 181.28078923,  131.18152745, ... , 141.15455416, 160.88972791])
      >>> tb.medabsdev(data)
      28.346646721370192

  note This implementation is robust to presence of NaNs

### Navigation

- index
- modules |
- modules |
- next |
- previous |
- homepage|
- search|
- documentation »
- toolbox - Toolbox of various functions and generic utilities »