RunningAverage Class on playground (updated)

updated Running Average Library to version 0.2.11 on GITHUB
Arduino/libraries/RunningAverage at master · RobTillaart/Arduino · GitHub -

The following changes were made since 0.2.08
(request aaronblanchard)

  • getAverage() renamed to getFastAverage() as it is fast but less accurate.
  • reimplemented getAverage() to be accurate, but a bit slower.
    getAverage() sums all elements in the internal buffer and average them. This solves the remark from aaronblanchard a few posts ago that the fastAverage() drifts from the real value. An example sketch is included to show this drift.

(request by mail)

  • added GetMinInBuffer() to make difference with getMin()

  • added GetMaxInBuffer() to make difference with getMin()
    Note getMin() and getMax() gives the minimum/maximum since last call to clear(). An example sketch shows the differences between the methods.

  • refactored

snippet from drift test (included as example)

COUNT       AVG	        FASTAVG     DIFF        MAXDIFF sofar
30750000	0.5153000	0.5152977	0.0000023	0.0000522
30760000	0.5241000	0.5240974	0.0000026	0.0000522

The sample sketch adds values between 0.0 and 0.999 in a loop. The maximum difference after 30 million++ additions is relative still low. There will be input streams which are more sensitive for the fastAverage algorithm. So when max accuracy is a requirement please use getAverage().

as always remarks and bug reports are welcome,
Rob