比如说,我有一个数组:
import numpy as np
x = np.array([0, 1, 2, 5, 6, 7, 8, 8, 8, 10, 29, 32, 45])
如何计算它的第 3 个标准差,以便得到 +3sigma
的值,如下图所示?
通常,我使用 std = np.std(x)
,但老实说,我不知道它返回的是 1sigma
值还是 2sigma
,或其他。我会非常感谢你的帮助。提前谢谢你。
最佳答案
NumPy 的 std
产生标准差,通常用“sigma”表示。要获得 2-sigma 或 3-sigma 范围,您可以简单地将 sigma 乘以 2 或 3:
print [x.mean() - 3 * x.std(), x.mean() + 3 * x.std()]
输出:
[-27.545797458510656, 52.315028227741429]
有关更详细的信息,您可以引用文档,其中指出:
The standard deviation is the square root of the average of the squared deviations from the mean, i.e., std = sqrt(mean(abs(x - x.mean())**2)).
http://docs.scipy.org/doc/numpy/reference/generated/numpy.std.html
关于python - 计算数组的第三个标准偏差,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28699342/