首页 > 代码库 > 极差,方差,标准差

极差,方差,标准差

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 vardef 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)