用python算方差可以借助numpy的向量运算来求更快速:
import numpy
narray=numpy.array(nlist)
sum1=narray.sum()
narray2=narray*narray
sum2=narray2.sum()
mean=sum1/N
var=sum2/N-mean**2
用python算方差可以借助numpy的向量运算来求更快速:
import numpy
narray=numpy.array(nlist)
sum1=narray.sum()
narray2=narray*narray
sum2=narray2.sum()
mean=sum1/N
var=sum2/N-mean**2