1

According to the documentation, the std function computes the standard deviation of each column. However, when I used the standard deviation formula for the first column, my result differed from that of Matlab.

The Matlab results are the following:

A = [4 -5 1; 2 3 5; -9 1 7];
S = std(A)
S = 1×3
7.0000    4.1633    3.0551

By using the Standard Deviation Formula for the first column, I got:

sqrt(((4 + 1) ^ 2 + (2 + 1) ^ 2 + ( - 9 + 1) ^ 2) / 3) =
5.71547606649

5.71547606649 is different from 7.00. What am I doing wrong D: ?

Thanks a lot for your time and have a wonderful day :D !

Tom Oconnor
  • 393
  • 2
  • 5
  • 14

1 Answers1

1

Look at the std formula. According to matlab documentation, which says sqrt(1/(N-1) etc) so you must divide by 2 not by 3 .

See the chapter More About of std documentation.

Also, you can use this to use the std formula with 1/N, std(A,1). The second input specifies the formula you want to use, with 0 you use 1/(N-1) formula (default) with 1 you use 1/N formula.

Peter Kühne
  • 3,224
  • 1
  • 20
  • 24
Andrea Bellizzi
  • 497
  • 5
  • 14