runningMean

utils.runningMean(oldMean, newValue, numValues)[source]

A running mean

Parameters:
  • oldMean (float) – The old running average mean
  • newValue (float) – The new value to be added to the mean
  • numValues (int) – The number of values in the new running mean once this value is included
Returns:

newMean – The new running average mean

Return type:

float

Notes

Based on Donald Knuth’s Art of Computer Programming, Vol 2, page 232, 3rd edition and taken from https://www.johndcook.com/blog/standard_deviation/

Examples

>>> runningMean(1, 2, 2)
1.5
>>> runningMean(1.5, 3, 3)
2.0