boostorg / accumulators

An awesome library from Boost
http://boost.org/libs/accumulators
22 stars 54 forks source link

Add exact calculation of higher order moments #25

Open NAThompson opened 5 years ago

NAThompson commented 5 years ago

I noticed here, line 58, that the variance is not calculated exactly, but rather calculated using an approximation.

I ran a git blame on this file as well as the higher order moments and found that at the time it was written (2008), there was no known exact, numerically stable, single pass, online algorithm which can compute higher order moments. This changed in 2009 with the publication of the following paper:

Updating the variance, covariance, skewness, kurtosis, and all higher order moments to use these formulas is no small task, but since the current approximation seems uncontrolled, at some point it seems like it is reasonable to add them to the accumulators library.