The formula for standard deviation involves dividing by the number of terms before square-rooting the result:

The function in your code, however, does not, and instead, simply sums the squares and then square-roots, giving a result that is always incorrect.
The formula for standard deviation involves dividing by the number of terms before square-rooting the result:

The function in your code, however, does not, and instead, simply sums the squares and then square-roots, giving a result that is always incorrect.