Standard Deviation formula linear form
10 views (last 30 days)
Show older comments
Hello! Have an array X=1xN. How to write the standard deviation formula in matlab (not to use the ‘std’ function)? I know the formula itself, but how is it written in a "linear" form? Thanks! My results is this:
sqrt = ((sum(sum(X)-mean(X)).^2)/(numel(X)-1))

Please, help to find mistake
0 Comments
Answers (1)
Walter Roberson
on 16 Aug 2020
You are assigning the result to a variable named sqrt instead of taking the square root of something.
You should not be taking sum(X) and subtracting the mean from that: you should be taking the sum of (squares of (X minus mean))
2 Comments
Walter Roberson
on 16 Aug 2020
- calculate X - mean(X)
- take squares of that vector
- sum result
- calculate number of elements in X, minus 1
- divide the sum by that
- take the square root of the result of the division
If you go through your code carefully you will see this is not what you are doing.
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!