def mad(a, c=0.6745, axis=0):
 _shape = a.shape
 a.shape = np.product(a.shape, axis=0)
 m = (np.median(np.fabs((a - np.median(a)))) / c)
 a.shape = _shape
 return m

def mad ( a , c = 0.6745 , axis = 0 ) : _shape = a . shape a . shape = np . product ( a . shape , axis = 0 ) m = ( np . median ( np . fabs ( ( a - np . median ( a ) ) ) ) / c ) a . shape = _shape return m
median absolute deviation: median(abs(a - median(a))) / c .