pandas中计算整体标准差

标准差(或方差),分为 整体标准差(方差)和 样本标准差(方差)。
前者分母为n,后者为n-1。后者是无偏的。
pandas里的 .std() 和 .var() 都是算的无偏的。
而numpy是有偏的。
 
那么在pandas里想算有偏的(即整体标准差或整体方差),怎么作?
参考这里。
 
 下面的内容复制自上述连接:

Pandas 0.8.1:git

import pandas as pd
a=pd.Series([0, 1, 3, 6])
a.mean(), a.std(), a.var()
a.values.mean(), a.values.std(), a.values.var()

I would expect both last lines to return the same result. However, the former returned:github

(2.5, 2.6457513110645907, 7.0)

and the latter:code

(2.5, 2.2912878474779199, 5.25)
上面是无偏,下面是有偏。
相关文章
相关标签/搜索