I want to do something very simple in MATLAB. I want to calculate the population standard deviation (i.e. I want the denominator n instead of n-1 as reviewed here).
The MATLAB default is to calculate the sample standard deviation. As in this example:
example = [0.555158185377949 0.572544871140911 0.566844451709150 0.585793022458150 0.577877363402946 0.564285735627449 0.582162844985863 0.576409646607226 0.583718583332482 0.577417064869028]
std(example)
ans =
0.0096
For MuPad, it appears that adding 'Population' should give me the population standard deviation. In MATLAB, adding 'Population' does give a result different from plain std():
test1=std(example,'Population')
test1 =
0.0087
But that result does not seem to be the same as the square root of the population variance:
sqrt(var(example,1))
ans =
0.0091
Note that the 'sample' standard deviation does equal the square root of the 'sample' variance, as you would expect:
sqrt(var(example))
ans =
0.0096
std(example)
ans =
0.0096
So the problem is just for population standard deviation. Am I missing something? Is there a MATLAB command to give the population standard deviation (instead of the sample standard deviation)? Or do I always need to take the square root of the population variance to calculate population standard deviation?
std? By default,stdnormalizes by N-1 (vartoo), not N as you seem to be stating. Switching between the two is just a matter of reading the documentation. Matlab and MuPAD are two separate environments – the functions and documentation are distinct so look at whichever is relevant to you. - horchlerhelp stdwill show you something similar. - horchler