Last active
August 29, 2015 13:59
-
-
Save tomr-stargazer/10671360 to your computer and use it in GitHub Desktop.
MAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def mad(x): | |
""" | |
Calculates the median absolute deviation of an array. | |
See http://en.wikipedia.org/wiki/Median_absolute_deviation | |
Parameters | |
---------- | |
x : np.ndarray | |
Array of numbers | |
Returns | |
------- | |
mad : float | |
Median absolute deviation | |
""" | |
return np.median(np.abs(x - np.median(x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment