The one-pass variance comes out negative on four numbers
For , , , (variance 30) the one-pass formula gives ; Welford's update gives 30.
one-pass formulaWelford
| Quantity | Viv | Checked by |
|---|---|---|
rel err one pass | 6.68889 | the 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