If I currently have a sum of N elements (I don't have the elements them self), their mean and the corresponding standard deviation. Later on I receive M (known) other elements. I want to update the mean and standard deviation that I already have according to this new elements. Is it possible to do so ?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
We need to save the sum of the $N$ elements (to be able to compute the mean later) as well as the sum of squared $N$ elements (to be able to compute the variance later). Then the variance when we have $M$ new elements will be: the last sum of squared N elements plus the sum of squared $M$ elements, minus the square of the new mean (which can be computed easily by dividing the sum of all elements by $N+M$).