runningSTD

utils.runningSTD(oldSTD, oldMean, newMean, newValue)[source]
Parameters:
  • oldSTD (float) – The old running average standard deviation
  • oldMean (float) – The old running average mean
  • newMean (float) – The new running average mean
  • newValue (float) – The new value to be added to the mean
Returns:

newSTD – The new running average standard deviation

Return type:

float

Notes

Based on Donald Knuth’s Art of Computer Programming, Vol 2, page 232, 3rd edition (which is based on B. P. Welford (2012) Note on a Method for Calculating Corrected Sums of Squares and Products, Technometrics, 4:3, 419-420, DOI: 10.1080/00401706.1962.10490022 This version is taken from https://www.johndcook.com/blog/standard_deviation/

Examples

>>> runningSTD(0, 1, 1.5, 2)
0.5
>>> runningSTD(0.5, 1.5, 2.0, 3)
2.0