gpt4 book ai didi

python - numpy 标准差给出的结果与 scipy stats 标准差不同

转载 作者:行者123 更新时间:2023-12-02 18:01:28 30 4
gpt4 key购买 nike

Scipy 和 numpy 标准差方法给出的结果略有不同。我不明白为什么。谁能给我解释一下吗?

这是一个示例。

import numpy as np
import scipy.stats
ar = np.arange(20)
print(np.std(ar))
print(scipy.stats.tstd(ar))

返回

5.766281297335398
5.916079783099616

最佳答案

不久前我就想到了......要获得相同的值

import numpy as np
import scipy.stats
ar = np.arange(20)
print(np.std(ar, ddof=1))
print(scipy.stats.tstd(ar))

输出#

5.916079783099616
5.916079783099616

我的导师常说

-->ddof=1 if you're calculating np.std() for a sample taken from your complete dataset.

---> ddof=0 if you're calculating for the full population

关于python - numpy 标准差给出的结果与 scipy stats 标准差不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74276989/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com