bug in robust.scale.mad? #1106

cossatot opened this Issue Oct 9, 2013 · 2 comments


None yet

3 participants

cossatot commented Oct 9, 2013

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...


duplicate of #658

jseabold commented Oct 9, 2013

Closing. Let's continue discussion on the other issue.

@jseabold jseabold closed this Oct 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment