Ignition Math

API Reference

6.4.0
RollingMean Class Reference

A class that computes the mean over a series of data points. The window size determines the maximum number of data points. The oldest value is popped off when the window size is reached and a new value is pushed in. More...

#include <RollingMean.hh>

Public Member Functions

 RollingMean (size_t _windowSize=10)
 Constructor. More...
 
 ~RollingMean ()
 Destructor. More...
 
void Clear ()
 Remove all the pushed values. More...
 
size_t Count () const
 Get the number of data points. More...
 
double Mean () const
 Get the mean value. More...
 
void Push (double _value)
 Insert a new value. More...
 
void SetWindowSize (size_t _windowSize)
 Set the new window size. This will also clear the data. Nothing happens if the _windowSize is zero. More...
 
size_t WindowSize () const
 Get the window size. More...
 

Detailed Description

A class that computes the mean over a series of data points. The window size determines the maximum number of data points. The oldest value is popped off when the window size is reached and a new value is pushed in.

Constructor & Destructor Documentation

◆ RollingMean()

RollingMean ( size_t  _windowSize = 10)
explicit

Constructor.

Parameters
[in]_windowSizeThe window size to use. This value will be ignored if it is equal to zero.

◆ ~RollingMean()

Destructor.

Member Function Documentation

◆ Clear()

void Clear ( )

Remove all the pushed values.

◆ Count()

size_t Count ( ) const

Get the number of data points.

Returns
The number of datapoints.

◆ Mean()

double Mean ( ) const

Get the mean value.

Returns
The current mean value, or std::numeric_limits<double>::quiet_NaN() if data points are not present.

◆ Push()

void Push ( double  _value)

Insert a new value.

Parameters
[in]_valueNew value to insert.

◆ SetWindowSize()

void SetWindowSize ( size_t  _windowSize)

Set the new window size. This will also clear the data. Nothing happens if the _windowSize is zero.

Parameters
[in]_windowSizeThe window size to use.

◆ WindowSize()

size_t WindowSize ( ) const

Get the window size.

Returns
The window size.

The documentation for this class was generated from the following file: