以numpy为单位的标准偏差 [英] Standard deviation in numpy

查看:280
本文介绍了以numpy为单位的标准偏差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

import numpy as np
print(np.std(np.array([0,1])))

它产生0.5

我相信这是不正确的.我在做什么错了?

I am confident that this is incorrect. What am I doing wrong?

推荐答案

默认情况下, numpy.std 返回总体标准偏差,在这种情况下,np.std([0,1])被正确报告为0.5.如果要查找样本标准偏差,则可以为std()提供一个可选的ddof参数:

By default, numpy.std returns the population standard deviation, in which case np.std([0,1]) is correctly reported to be 0.5. If you are looking for the sample standard deviation, you can supply an optional ddof parameter to std():

>>> np.std([0, 1], ddof=1)
0.70710678118654757

ddof修改样本的平方和减去均值的除数.除数为N - ddof,从结果中可以看到默认的ddof0.

ddof modifies the divisor of the sum of the squares of the samples-minus-mean. The divisor is N - ddof, where the default ddof is 0 as you can see from your result.

这篇关于以numpy为单位的标准偏差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆