C Assignment I need help Explain how do I use a formula for
C++ Assignment: I need help!
Explain how do I use a formula for standard deviation, thank you!
Solution
For standard deviation, first run a for loop calculating two things in two different variables, sum of all elements in array and sum of squares of elements in array .
Once we got these values in variables say , sumElements and sumSquareElements
Next, do this : multiply sumSquareElements with n, and subtract square of sumElements from it, and get the value in say var V. Now divide V by (n*(n-1)) and use the function sqrt in C++ <cmath> library to return the square root.
One thing to note is that, when dividing V by (n*(n-1)), V would be an integer, and resulting value would be rounded off, so it is better to do it as : (V*1.0)/(n*(n-1))
