Next I present the code made, I create the DMA function which has the formula of the absolute mean deviation, the other two print's compute the DMA of the stats package and robust, as we see both results are different, I do not understand why the estimation of the functions differs so much from the one I manually create
import numpy as np
import scipy.stats as stats
from statsmodels import robust
def MAD (vector):
MAD = np.sum(np.abs(vector-np.mean(vector)))/len(vector)
return(MAD )
print("MAD ",DMA([1.5,0,4,2.5]))
print("MAD function from stats", stats.median_absolute_deviation([1.5,0,4,2.5],axis=0))
print("MAD function from robust", robust.mad([1.5,0,4,2.5]))
Results:
MAD 1.25
MAD function from stats 1.8532499999999998
MAD function from robust 1.8532527731320025