|
Gin
|
Maintains a rolling average of a series of numbers. More...
#include <gin_util.h>
Public Member Functions | |
| RollingAverage (int numVals_) | |
| Creates a RollingAverage with the specified weighting factor. | |
| double | average (double nextValue) |
| Updates the rolling average with a new value and returns the new average. | |
| double | getAverage () |
| Returns the current rolling average value. | |
| void | setAverage (double avg) |
| Sets the current rolling average to a specific value. | |
Maintains a rolling average of a series of numbers.
This class computes a running average that incorporates new values while maintaining a weighted influence from previous values. Useful for smoothing time-series data.
| RollingAverage::RollingAverage | ( | int | numVals_ | ) |
Creates a RollingAverage with the specified weighting factor.
| numVals_ | The number of values to weight the current average by when incorporating new values. Higher values give more weight to the existing average. |
Updates the rolling average with a new value and returns the new average.
| nextValue | The new value to incorporate into the average |
| double RollingAverage::getAverage | ( | ) |
Returns the current rolling average value.
Sets the current rolling average to a specific value.
| avg | The new average value |