Skip to content
All library documents

Welford’s Method for Numerically Stable Online Variance

Article MQL5 code base

Summary

The document introduces variance and standard deviation as measures of data dispersion, then points to Welford’s single-pass method for computing variance. This approach is relevant when observations arrive sequentially or when a full dataset is inconvenient to retain, making it useful for streaming statistics in quantitative research.

Its main numerical caution is that straightforward variance calculations can lose precision when variance is small relative to the squared mean: subtracting similar large quantities can cause catastrophic cancellation. Welford’s method is presented as a way to avoid this failure mode. The page offers no derivation, implementation details, benchmark, or trading example, so it serves as a brief pointer to a useful statistical technique rather than a complete guide. It also does not specify conventions such as sample versus population variance in enough detail to reproduce a particular calculation.

Key ideas

  • Standard deviation expresses the spread of observations around their mean and is derived from variance.
  • Welford’s method computes variance in a single pass over observations.
  • The method addresses precision loss when variance is tiny compared with the squared mean.
  • The document gives no implementation, worked example, or trading application.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.