Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|cite|improve this question
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
up vote 2 down vote accepted

If your data is a sample, you should use the sample variance


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.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.