Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have a distribution that will continuously have numbers added to it as they are measured. I want to keep only knowledge of the mean, the standard deviation, and the number of values so far in the distribution.
How would I go about adding a new value to the distribution and correctly recalculating the standard deviation? (I can do the mean).
Thanks!

share|improve this question

1 Answer 1

Let's write the mean when we have $N$ values as $\bar x_N$. Then: $$ \bar x_{N+1}=\frac{1}{N+1}\sum_{i=1}^{N+1}x_i=\frac{N}{N+1}\frac{1}{N}\sum_{i=1}^{N}x_i+\frac{1}{N+1}x_{N+1}= $$ $$ =\frac{N}{N+1}\bar x_N+\frac{1}{N+1}x_{N+1} $$ You already had it, but I didn't remember it and it is necessary for the next one. Notating the standard deviation when we have $N$ values as $\sigma_N$: $$ \sigma^2_{N+1}=\frac{1}{N+1}\sum_{i=1}^{N+1}(x_i-\bar x_{N+1})^2=\frac{1}{N+1}\sum_{i=1}^{N+1}(x_i^2-\bar x_{N+1}^2) $$

$$ =\frac{N}{N+1}\frac{1}{N}\sum_{i=1}^{N}(x_i^2-\bar x_{N}^2)+\frac{1}{N+1}\sum_{i=1}^{N}(\bar x_{N}^2-\bar x_{N+1}^2)+\frac{1}{N+1}(x^2_{N+1}-\bar x^2_{N+1}) $$ $$ =\frac{N}{N+1}\sigma^2_N+\frac{N}{N+1}(\bar x_{N}^2-\bar x_{N+1}^2)+\frac{1}{N+1}(x^2_{N+1}-\bar x^2_{N+1}) $$ I think that it should be enought.

share|improve this answer

Your Answer

 
discard

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.