I am converting some MatLab code to Python, and cannot solve why the results I am getting are different.
In MatLab, the mad function on the input x = [1, 2, 4, 3, 7, 2, 1, 3, 2, 1] yields a result of 1.32. However, when using the equiv function in SciPy.Stats, that is, median_abs_deviation, I get a different result of 1.0.
My code, exactly is:
Matlab:
x = [1, 2, 4, 3, 7, 2, 1, 3, 2, 1];
mdat = mad(x)
Python:
from scipy import stats
x = np.array([1, 2, 4, 3, 7, 2, 1, 3, 2, 1])
print(stats.median_abs_deviation(x))