I am puzzled by the Wikipedia entry discussing many online algorithms for computing the sample variance, including the Welford's online algorithm.
In particular, the sample variance $s_n^2$ can be computed from the sample $\{X_1,..,X_n\}$ as: $$ x_n = \frac{n-1}n x_{n-1} + \frac 1n X_n $$ $$ s_n^2=\frac{n-2}{n-1}s_{n-1}^2+\frac 1n(X_n-x_{n-1})^2 $$ with the caveat that
These formulas suffer from numerical instability, as they repeatedly subtract a small number from a big number which scales with n.
I can see it, because for $n\to\infty$ the first term is of the order of the variance, while the second goes to 0. I can see the numerical issue arising from the finite precision of a float.
The entry goes on arguing that the Welford's online algorithm is designed to tackle this issue: $$ M^2_n = M^2_{n-1}+(X_n-x_n)(X_n-x_{n-1}),\qquad s^2_n=\frac{M^2_n}{n-1}. $$
My question is: how does it solve it? I don't see it happening. $M_{n-1}^2$ is a sum of terms looking like the second one, so not only is prone to overflow, but also to become too big with respect to the second term, that may eventually become smaller than the last digit of $M_{n-1}^2$. It seems to me that no improvement is achieved, apart of risking floating point overflow ..