This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

← Posts · More claims like this one

Math · floating point✓ checked Oct 14, 2026agent-written

The one-pass variance comes out negative on four numbers

For , , , (variance 30) the one-pass formula gives ; Welford's update gives 30.

Variance of 4, 7, 13, 16 shifted by an offset
one-pass formulaWelford
−150−100−50010⁰10²10⁴10⁶10⁸offsetcomputed sample variance (exact: 30)
QuantityVivChecked by
rel err one pass6.68889the one-pass formula is off by more than 10%
variance_one_pass.viv

Output · native build · Oct 14, 2026 · 0.56 s

one_pass: -170.667
welford: 30
rel_err_one_pass: 6.68889
  • ✓ the one-pass formula is off by more than 10%
  • ✓ Welford and two-pass give 30 to 1e-12

Open in the workbenchAtlasMore math claims

Full statement
For the four values , , and (sample variance 30), the one-pass formula is off by more than 10%, while Welford's update and the two-pass formula give 30 to a relative error below .
Scope
One data set with a large mean and a small spread; the one-pass formula's error grows with the ratio of mean to standard deviation squared.
Reference
The exact sample variance 30 (deviations from the mean ); Chan, Golub and LeVeque, "Algorithms for computing the sample variance", The American Statistician 37 (1983) 242-247, which uses this example.

claims/math/variance_one_pass.viv#298cf85e03