22[ ![ Arduino CI] ( https://github.com/RobTillaart/RunningAverage/workflows/Arduino%20CI/badge.svg )] ( https://github.com/marketplace/actions/arduino_ci )
33[ ![ Arduino-lint] ( https://github.com/RobTillaart/RunningAverage/actions/workflows/arduino-lint.yml/badge.svg )] ( https://github.com/RobTillaart/RunningAverage/actions/workflows/arduino-lint.yml )
44[ ![ JSON check] ( https://github.com/RobTillaart/RunningAverage/actions/workflows/jsoncheck.yml/badge.svg )] ( https://github.com/RobTillaart/RunningAverage/actions/workflows/jsoncheck.yml )
5+ [ ![ GitHub issues] ( https://img.shields.io/github/issues/RobTillaart/RunningAverage.svg )] ( https://github.com/RobTillaart/RunningAverage/issues )
6+
57[ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-green.svg )] ( https://github.com/RobTillaart/RunningAverage/blob/master/LICENSE )
68[ ![ GitHub release] ( https://img.shields.io/github/release/RobTillaart/RunningAverage.svg?maxAge=3600 )] ( https://github.com/RobTillaart/RunningAverage/releases )
9+ [ ![ PlatformIO Registry] ( https://badges.registry.platformio.org/packages/robtillaart/library/RunningAverage.svg )] ( https://registry.platformio.org/libraries/robtillaart/RunningAverage )
710
811
912# RunningAverage
@@ -21,14 +24,31 @@ The size of the internal buffer can be set in the constructor.
2124
2225By keeping track of the ** \_ sum** the runningAverage can be calculated fast (only 1 division)
2326at any time. This is done with ** getFastAverage()** .
24- However the constant adding and subtracting when adding new elements possibly introduces an ever increasing error.
27+ However the constant adding and subtracting when adding new elements to the RA object possibly
28+ introduces an ever increasing error.
2529In tests adding up to 1500000 numbers this error was always small. But that is no proof.
2630In version 0.2.16 a fix was added that uses the calculation of the sum in ** getAverage()** to
2731update the internal ** \_ sum** .
2832
2933
34+ #### Related
35+
36+ - https://github.com/RobTillaart/Correlation
37+ - https://github.com/RobTillaart/GST - Golden standard test metrics
38+ - https://github.com/RobTillaart/Histogram
39+ - https://github.com/RobTillaart/RunningAngle
40+ - https://github.com/RobTillaart/RunningAverage
41+ - https://github.com/RobTillaart/RunningMedian
42+ - https://github.com/RobTillaart/statHelpers - combinations & permutations
43+ - https://github.com/RobTillaart/Statistic
44+
45+
3046## Interface
3147
48+ ``` cpp
49+ #include " RunningAverage.h"
50+ ```
51+
3252### Constructor
3353
3454- ** RunningAverage(uint16_t size)** allocates dynamic memory, one float (4 bytes) per element.
@@ -40,8 +60,10 @@ No default size (yet).
4060
4161- ** void clear()** empties the internal buffer.
4262- ** void add(float value)** wrapper for ** addValue()**
43- - ** void addValue(float value)** adds a new value to the object, if internal buffer is full, the oldest element is removed.
44- - ** void fillValue(float value, uint16_t number)** adds number elements of value. Good for initializing the system to z certain starting average.
63+ - ** void addValue(float value)** adds a new value to the object, if the internal buffer is full,
64+ the oldest element is removed.
65+ - ** void fillValue(float value, uint16_t number)** adds number elements of value.
66+ Good for initializing the system to a certain starting average.
4567- ** float getValue(uint16_t position)** returns the value at ** position** from the additions.
4668Position 0 is the first one to disappear.
4769- ** float getAverage()** iterates over all elements to get the average, slower but accurate.
@@ -68,15 +90,15 @@ Needs more than one element to be calculable.
6890- ** uint16_t getCount()** returns the number of slots used of the internal array.
6991
7092
71- ## Partial
93+ ## Partial functions
7294
7395- ** void setPartial(uint16_t partial = 0)** use only a part of the internal array.
7496Allows to change the weight and history factor.
75970 ==> use all == default.
7698- ** uint16_t getPartial()** returns the set value for partial.
7799
78100
79- ## Last
101+ ## Last functions
80102
81103These functions get the basic statistics of the last N added elements.
82104Returns NAN if there are no elements and it will reduce count if there are less than
@@ -92,7 +114,7 @@ numbers of the whole buffer to notice changes earlier.
92114Otherwise one should create multiple RunningAverage objects each with its own length,
93115effectively having multiple copies of the data added.
94116
95- Note: if called with a value larger or equal to ** getCount()** (incl ** getSize()** ) as
117+ Note: if called with a value larger or equal to ** getCount()** (including ** getSize()** ) as
96118parameter, the functions will return the statistics of the whole buffer.
97119
98120
@@ -109,15 +131,40 @@ See examples
109131
110132## Future
111133
112- #### must
134+
135+ #### Must
136+
113137- update documentation, explain better
114138
115- #### should
116- - add error handling (important?)
139+ #### Should
140+
117141- check for optimizations.
142+ - divide by count happens often ...
118143- clear(bool zero = true) to suppress setting all to 0. ?
119144
120- #### could
121- - default size for constructor
145+ #### Could
146+
122147- create a double based derived class? Template class?
148+ - add error handling (important?).
149+ - investigate ** modus()** most frequently occurring value.
150+ - difficult with floats ?
151+ - what to do when on two or more values are on par?
152+
153+ #### Wont
154+
155+ - default size for constructor
156+ - unknown what would be a good choice.
157+ - clear(bool zero = true) to suppress setting all to 0. ?
158+ - makes ** addValue()** slightly more complex
159+ - could introduce conflicts due to randomness data?
160+
161+
162+ ## Support
163+
164+ If you appreciate my libraries, you can support the development and maintenance.
165+ Improve the quality of the libraries by providing issues and Pull Requests, or
166+ donate through PayPal or GitHub sponsors.
167+
168+ Thank you,
169+
123170
0 commit comments