def Var(t, mu=None): """方差""" if mu is None: mu = Mean(t) # compute the squared deviations and return their mean. dev2 = [(x - mu)**2 for x in t] var = Mean(dev2) return var def StdVar(t, mu=None): """标准差""" if mu is None: mu = Mean(t) import math return math.sqrt(Var(t, mu)) def Range(t): """极差""" if not t: return None return max(t) - min(t)
原文:http://www.cnblogs.com/data80386/p/3842363.html