Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
bug in robust.scale.mad? #1106
I believe there is a bug in the median absolute deviation function.
The code (def mad, lines 17-37 in statsmodels.robust.scale.py) appears to simply calculate the median of an array, scale it by the normalization constant, and return that. I.e. there is no step of dividing the array by the median.
The entire code is:
def mad(a, c=Gaussian.ppf(3/4.), axis=0): # c \approx .6745 a = np.asarray(a) return np.median((np.fabs(a))/c, axis=axis)
and should be at least:
def mad(a, c=Gaussian.ppf(3/4.), axis=0): # c \approx .6745 a = np.asarray(a) d = np.median(a) return np.median((np.fabs(a - d))/c, axis=axis)
I am happy to submit a PR, assuming that I am not wrong, but since I'm not previously a contributor I would ask for permission before doing so...