Welford Online Statistics
📐 Definition
Section titled “📐 Definition”Given samples , maintain mean and accumulated second moment via
initialized with , , . The variance is (population) or (unbiased, ).
Domain and Codomain
Section titled “Domain and Codomain”Applies to real or complex data streams with finite second moments. For complex data with variance defined as , a common update is
which keeps real and nonnegative.
⚙️ Key Properties
Section titled “⚙️ Key Properties”Single-pass and numerically stable; accumulates squared deviations without storing history. Order-invariant: results depend only on the multiset of samples, not their order.
For constant data, variance remains zero. As for stationary processes with finite variance, estimates converge almost surely to true moments.
🎯 Special Cases and Limits
Section titled “🎯 Special Cases and Limits”- Constant stream yields zero variance.
- Suitable for long streams where two-pass variance would be numerically fragile or memory-intensive.
🔗 Related Functions
Section titled “🔗 Related Functions”Exponential moving averages provide biased but rapidly adapting moments; basic variance formulas require two passes or stored history.
Usage in Oakfield
Section titled “Usage in Oakfield”Oakfield uses Welford-style online accumulation in its runtime field statistics engine:
SimFieldStatsAccumulatorupdates mean and M2 in a single pass over field data (numerically stable, streaming-friendly).- The resulting means/variances (plus magnitude moments) feed UI diagnostics and downstream metrics without storing full histories.
Historical Foundations
Section titled “Historical Foundations”📜 One-Pass Variance
Section titled “📜 One-Pass Variance”Welford’s update is a classic numerically stable one-pass method for mean and variance computation and is widely used in streaming statistics.
🌍 Modern Perspective
Section titled “🌍 Modern Perspective”It is a standard building block for online diagnostics and adaptive methods that must track variance without storing history.
📚 References
Section titled “📚 References”- Welford, “Note on a Method for Calculating Corrected Sums of Squares and Products” (1962)
- Chan, Golub, LeVeque, “Algorithms for Computing the Sample Variance” (1983)