Variance looks like it needs two passes: one to find the mean, one to sum the squared deviations. Or one pass and the treacherous Σx² − (Σx)²/n, which subtracts two huge nearly-equal numbers and loses all precision. Welford's method does neither. It carries exactly two running numbers — the mean and M₂, the running sum of squared deviations — and updates both per sample: δ=x−m; m′=m+δ/n; M₂+=δ·(x−m′). One pass, a bounded compound summary, and numerically stable. A correct batch variance must retain all n values; a correct naive one-pass keeps two sums but loses the precision. Welford's mechanism supplies exactly what both correct alternatives lack.
Eight samples streamed once. The demo carries the pair [mean, M₂] and reports the variance — the data is never stored, and the subtraction that kills precision never happens: live demo
“Variance needs two passes, or a fragile one.” — Welford carries two numbers, updates them once per sample, and is stable: no giant cancellation, no stored data. The correct textbook formula and the correct one-pass formula both lack what this has. cited
Two numbers, streamed once, stable by construction. The variance that never subtracts two mountains to find a molehill. Welford 1962
On the canonical compiler, streaming [2,4,4,4,5,5,7,9] and carrying the pair [m, M₂] through a single pass gives mean = 5, variance = 4 — and the state threaded is a two-element array, not the eight samples: