Welford’s algorithm for accurate computation of weighted mean, variance, and covariance

Alexey Shagraev, Andrey Efanov, Sergey Ivliev
15m
The Wellford method is a simple and effective way to calculate averages, variances, covariances, and other statistics. This method has several excellent properties: • achieves high performance on the accuracy of decisions; • it is straightforward to understand and implement; • it is a one-pass online algorithm, which is extremely useful in some situations. Wellford’s original article published in 1962. Nevertheless, the algorithm is not widely known at present. Moreover, it is a non-trivial task to find a mathematical proof of its correctness or experimental comparisons with other methods. This article attempts to fill these gaps.