[Math] Calculating average without knowing number of elements

averageinduction

I would like to calculate the average of a a set of numbers without knowing the sum of the set. In other words, I want to calculate the average with knowing as little information as possible.

Note: I do not want to use $\frac{sum}{total}$

I am using looping (induction, I believe) to calculate the average.

I would like to keep track of only one variable, say x, which is equal to the current accuracy.

Is it possible to calculate x without knowing sum?

In summary: seeking how can you calculate the new average knowing only the number of elements and the current average.

Best Answer

Notice that sum is the current average times the current number of elements...

Suppose that $a(n)$ is the average of the first $n$ elements of the set and $e$ is the $n+1^{\text{st}}$ element. Then $$ a(n+1) = \frac{n a(n) + e}{n+1} \text{.} $$ Of course, all this does is reconstruct sum, update it with the new element and then divide to get the new running average.

Related Question