paj*_*aco 4 python statistics numpy
我正在尝试对一组3个数字进行简单的方差计算:
numpy.var([0.82159889, 0.26007962, 0.09818412])
Run Code Online (Sandbox Code Playgroud)
返回
0.09609366366174843
Run Code Online (Sandbox Code Playgroud)
但是,当您计算方差时,它实际应该是
0.1441405
Run Code Online (Sandbox Code Playgroud)
看起来像这么简单,但我还没有找到答案.
正如文档所述:
ddof : int, optional
"Delta Degrees of Freedom": the divisor used in the calculation is
``N - ddof``, where ``N`` represents the number of elements. By
default `ddof` is zero.
Run Code Online (Sandbox Code Playgroud)
所以你有:
>>> numpy.var([0.82159889, 0.26007962, 0.09818412], ddof=0)
0.09609366366174843
>>> numpy.var([0.82159889, 0.26007962, 0.09818412], ddof=1)
0.14414049549262264
Run Code Online (Sandbox Code Playgroud)
这两个约定都很常见,您总是需要检查您正在使用的任何包,正在使用哪种语言.