0
$\begingroup$

Having 2 sets, and only this data for each one, the running variance, the sum, the running mean and the count. How can I get the merged variance of the 2 sets?

EDIT:

The values of the sets are being updated each time with new ocurrences this ocurrences are not being stored.

The values of the sets are not equal.

I need to merge this 2 sets and get the new variance of this merged set.

EDIT 2:

I think that what I need is the pooled variance, am I correct?

In java would be something like this

Double variance = (((firstAggregate.count - 1) * firstAggregate.variance) + ((secondAggregate.count - 1) * secondAggregate.variance)) / ((otherAggregate.count + secondAggregate.count) - 2);
$\endgroup$
2
  • $\begingroup$ Could you be more specific, please add more details to your question $\endgroup$ Commented Jun 10, 2020 at 8:21
  • $\begingroup$ Done, do you need more information? Im new to statistics $\endgroup$
    – Bentipe
    Commented Jun 10, 2020 at 8:47

1 Answer 1

1
$\begingroup$

There's no need to merge two sets and compute the variance, it's a time consuming task you can compute the variance for each of them separately, then update the total variance. Updating variance could be done by using an update formula. updating formula

$T_1,_m = \sum_{i=1}^{m} x_i \\$

$S_1,_m = \sum_{i=1}^{m} (x_i - \frac{1}{m}*T_1,_m)^2 \\$

The equation discussed at a pairwise algorithm for computing sample variances paper.


Update

Parallel algorithm

$\endgroup$
2
  • 1
    $\begingroup$ thank you @m-zayan that pairwise algorithm is what in wikipedia is called the parallel algorithm, and is what I need, if you could add it to your answer so it can be more complete :) en.wikipedia.org/wiki/… $\endgroup$
    – Bentipe
    Commented Jun 12, 2020 at 9:29
  • $\begingroup$ you are welcome, note the edit of the T, T is the sum over all elements in the set not (mean). I have added it, thanks. $\endgroup$
    – 4.Pi.n
    Commented Jun 12, 2020 at 15:33

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