Why is MATLAB calculation of standard deviation different than a hand calculation?

前端 未结 1 1912
抹茶落季
抹茶落季 2021-01-24 14:59

Matlab:

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

Layman\'s interpretation of standard deviation per Google:

Mean of {3,2,2,3}         


        
相关标签:
1条回答
  • 2021-01-24 15:38

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

    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.

    So you have

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

    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.

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

    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).

    0 讨论(0)
提交回复
热议问题