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)
极差,方差,标准差
时间: 2024-10-13 18:32:26