3

i'm taking some measurements... Let's say i don't have the luxury to store each individual value but i can only store the sum of all measures and their number (and any other such aggregate data). For example, when a new measurement comes in i do this:

sum = sum + newValue; number = number + 1; average = sum / number;

So i can keep basically any such info like the sum and number but not individual values. Is there a way that allows me to calculate standard deviation like this as well? Incrementally? Is there something else similar to standard deviation that i can calculate like this?

Thanks!

UPDATE: From @Chinny i understand this is called a rolling standard deviation and @user121049 gave me an answer.

I ended up using what is called a "running standard deviation" as called on Wikipedia: http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods

Sandman
  • 133

1 Answers1

4

Yes if you keep the sum of the squares. $\sum(x_i-\bar{x})^2=\sum x_i^2 -n \bar{x}^2$

user121049
  • 1,599
  • Is that a rolling average? I have nothing else but a rolling one i can't get a final one. – Sandman Feb 20 '14 at 11:59
  • Yes, just add sum2=sum2+newValuenewValue to your list then standard deviation = SQRT[(sum2 - sumsum/number)/(number-1)] – user121049 Feb 20 '14 at 12:58