Consider I have two sequences of numbers: 1 and 2. I don't have these sequences exactly but I know their means and numbers of elements in them: mean1, mean2, count1, count2.
I need to calculate mean of both sequences together knowing only means and counts of those sequences separately. The obvious formula is: mean12 = (mean1 * count1 + mean2 * count2)/(count1 + count2).
What I want to know: is there a way to calculate mean12 without multiplying mean1 * count1 and mean2 * count2. The reason for this: for my task mean and count could be huge numbers and multiplication could cause overflow, so I want to know if there is another solution, which avoids multiplication of those huge numbers.