为什么MATLAB的标准差计算与手动计算不同? [英] Why is MATLAB calculation of standard deviation different than a hand calculation?

查看:318
本文介绍了为什么MATLAB的标准差计算与手动计算不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab:

>> std( [3 2 2 3] )
ans =
    0.5774

Layman对每个

Layman's interpretation of standard deviation per Google:

Mean of {3,2,2,3} = 2.5
Deviation from mean for each value = {0.5, 0.5, 0.5, 0.5}
Square of deviation from mean = {0.25, 0.25, 0.25, 0.25}
Mean of the squares = 0.25
Square root of 0.25 = 0.5
Therefore Standard Deviation of {3,2,2,3} = 0.5

我做了什么?我愚蠢地期望这两个数字能够达成共识.

What did I muck up? I was foolishly expecting those two numbers to agree.

推荐答案

Matlab std计算 校正的标准偏差.来自help std:

Matlab std computes the corrected standard deviation. From help std:

std通过(N-1)归一化Y,其中N是样本大小.这是 人口方差的无偏估计的平方根 只要X由相同的独立元素组成 分布的样本.

std normalizes Y by (N-1), where N is the sample size. This is the sqrt of an unbiased estimator of the variance of the population from which X is drawn, as long as X consists of independent, identically distributed samples.

所以你有

Square of deviation from mean = {0.25, 0.25, 0.25, 0.25}

然后,您没有计算偏差的实际均方根,而是sqrt(sum([0.25 0.25 0.25 0.25])/3).通常,sum(square of deviation)/(N-1)用于长度为N的向量.

Then you don't compute the actual root mean of the deviations, but sqrt(sum([0.25 0.25 0.25 0.25])/3). Generally, sum(square of deviation)/(N-1) for a vector of length N.

更新:如 Leonid Beschastny 指出的那样,您可以让matlab进行计算未校正的标准偏差.同样,来自help std:

Update: as Leonid Beschastny pointed out, you can get matlab to calculate the uncorrected standard deviation. Again, from help std:

Y = std(X,1)通过N归一化并产生第二个平方根 关于样本均值的时刻. std(X,0)与std(X)相同.

Y = std(X,1) normalizes by N and produces the square root of the second moment of the sample about its mean. std(X,0) is the same as std(X).

这篇关于为什么MATLAB的标准差计算与手动计算不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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