TITLE: How many decimal places are needed for incremental average calculation?
QUESTION [6 upvotes]: If using the following formula to incrementally calculate average value:
$$m_n = m_{n-1}  + \frac{a_{n}-m_{n-1}}{n}$$
And the number of decimal places to where you can save $m_n$ is limited to $d$ decimal digits, how many $n$ values can you use to incrementally calculate average before the rounding error becomes larger than $10^{-p}$, if the value of $a_n$ is always exactly $p$ decimal digit precise?

REPLY [3 votes]: You have used $base-10$ notation and hence, I am doing the analysis in the same, but to do the actual analysis for a computer, I believe, it would be best for you to do it using the $base-2$.
Since we can have only $d$ decimal places, in every division which is not done by $10$ and the odd case where the mantissa when represented without the point and hence as an integer is a multiple of the divisor, you introduce an error of $10^{-d}$ at every stage (for binary computers, you would lose $2^{-d}$). This is only for this particular formula, since here divisor is integer and hence, no error comes from the divisor. 
Also, suppose at some stage $m_{k} = c_{k} \times 10^{q_{k}}$ and $a_{k} = d_{k} \times 10^{r_{k}}$, then adding or subtracting them introduces an error of $10^{q_{k}-r_{k}-d}$ assuming $q > r$. So, now we can add up these operations. So, now your total error accumulated would be 
$\varepsilon = \sum_{k=0}^{k=n} 2 \times10^{\left(q_{k}-r_{k}-d\right)}  + 10^{-d}$
So, then going by the rule-of-thumb in the best case where $q_{k} = r_{k}$, I guess, you will be done in at around 4 steps after which your error is of the order of $10^{-d+1}$
So, this is a rough hand calculation without assuming anything about the system and hence the maximum error I will say but you can get some detailed analysis at this document by Oracle on error calculation.