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

前端 未结 10 1570
故里飘歌
故里飘歌 2020-12-23 16:36

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

10条回答
  •  -上瘾入骨i
    2020-12-23 17:31

    I'm using:

    from math import fabs
    
    a = [1, 1, 2, 2, 4, 6, 9]
    
    median = sorted(a)[len(a)//2]
    
    for b in a:
        mad = fabs(b - median)
        print b,mad
    

提交回复
热议问题