Say we have the below data:
- 100
- 120
- 80
- 110
The average of these is 84.5
Is there any way, I can store some data from this original data and calculate new average when a new no. is added? For example, now a new no. 100 is added.
Now if I know the count of no.s till now was 4 and the old average was 84.5 is there a way to get new average without knowing what those 4 no.s was? Is there a mathematical solution to store some other single data and to avoid knowing all no.s for future calculations?
I am exploring this to solve a problem where there will be 1000s of digits and it is hard to be stored. In the use case, absolute accuracy is not a requirement.
You indeed don't need the numbers, only their sum (and count).
In the given example after 3 numbers say you have only the average 100. And the forth number is 110 then the new average will be:
$$ \frac{100*3 + 110}{4} = 102.5 $$