Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where can I find mad (mean absolute deviation) in scipy?

It seems scipy once provided a function mad to calculate the mean absolute deviation for a set of numbers:

http://projects.scipy.org/scipy/browser/trunk/scipy/stats/models/utils.py?rev=3473

However, I can not find it anywhere in current versions of scipy. Of course it is possible to just copy the old code from repository but I prefer to use scipy's version. Where can I find it, or has it been replaced or removed?

like image 321
Ton van den Heuvel Avatar asked Jan 19 '12 17:01

Ton van den Heuvel


People also ask

How do you find mad in R?

MAD = median(|xi – xm|) where: xi: The ith value in the dataset. xm: The median value in the dataset.


1 Answers

[EDIT] Since this keeps on getting downvoted: I know that median absolute deviation is a more commonly-used statistic, but the questioner asked for mean absolute deviation, and here's how to do it:

from numpy import mean, absolute  def mad(data, axis=None):     return mean(absolute(data - mean(data, axis)), axis) 
like image 164
mhsmith Avatar answered Oct 08 '22 20:10

mhsmith