standard deviation computation

126 Views Asked by At

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 ?

1

There are 1 best solutions below

0
On BEST ANSWER

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$).