# How to calculate standard deviation for a series containing both positive and negative numbers?

I got a stream of numbers in one of my apps to represent an electrical signal. I've observed that the signal ranges from -100 to +100. Other than that, the signal is fairly random and crosses 0 in most cases. I'm trying to understand if I'm calculating the standard deviation of this stream of numbers correctly.

• I collect 1000 data points
• I add all the data points and divide by 1000 to calculate the mean < This is the step that I'm not sure of. Do I need to add absolute values to calculate the mean if there are both positive and negative numbers?
• I calculate the sum of square of differences for each value (value - mean)^2
• I take a square root of the (sum of square differences divided by 1000) to get standard deviation

The result I get is something like 46.6 I'm trying to understand if this number appears correct given the steps above, or if I need to adjust how I calculate standard deviation to account for having negative numbers mixed with positive.

Thank you!

-
Don't add absolute value signs. Intuitively, there's nothing special about the choice of $0$ in your unit system, that is, if you shift all the points by $k$, the mean should shift by $k$ also. This evidently won't happen if you add the absolute values. –  Alyosha Feb 22 '13 at 15:22
Example: the mean of $-4$ and $2$ is evidently $-1$, not $3$. –  Alyosha Feb 22 '13 at 15:24
A standard deviation of $46.6$ sounds quite believable for data that is scattered between $-100$ and $100$. If the data were truly uniform, it would be about $57.73$ –  Ross Millikan Feb 22 '13 at 20:50

$s^2=\frac{1}{n-1}\sum_{i=1}^n(x_i-\bar{x})^2$
as it is an unbiased estimator (note the n-1 in the denominator). The standard deviation is given as described above by $s=\sqrt{s^2}$. As Alyosha mentioned, do not use the absolute numbers, but the real values of x given by the experiment.