Maintain running statistics for a data stream
Implementation adapted from:
https://www.johndcook.com/blog/standard_deviation/
"There is a way to compute variance that is more accurate and is guaranteed to always give positive results. Furthermore, the method computes a running variance. That is, the method computes the variance as the x‘s arrive one at a time. The data do not need to be saved for a second pass.
This better way of computing variance goes back to a 1962 paper by B. P. Welford and is presented in Donald Knuth’s Art of Computer Programming, Vol 2, page 232, 3rd edition."