| Mozzi version v1.1.0 sound synthesis library for Arduino |

Public Member Functions | List of all members
RollingStat< T, WINDOW_LENGTH > Class Template Reference

WARNING: this class is work in progress, don't use it yet. More...

`#include <RollingStat.h>`

## Public Member Functions
| RollingStat ()
| Constructor.
void | update (T x)
| Update the mean and variance given a new input value. More...
void | update (int8_t x)
| Update the mean and variance given a new input value. More...
T | getMean () const
| Return the mean of the last WINDOW_LENGTH number of inputs. More...
T | getVariance () const
| Return the approximate variance of the last WINDOW_LENGTH number of inputs. More...
T | getStandardDeviation () const
| Return the approximate standard deviation of the last WINDOW_LENGTH number of inputs. More...

## Detailed Description

### template<class T, int WINDOW_LENGTH>
class RollingStat< T, WINDOW_LENGTH >

WARNING: this class is work in progress, don't use it yet.

Calculates an approximation of the variance and standard deviation for a window of recent inputs.

Template Parameters

  T | the type of numbers to use. Choose unsigned int, int , uint8_t, int8_t, or float
  WINDOW_LENGTH | how many recent input values to include in the calculations.

Definition at line 28 of file RollingStat.h.

## Member Function Documentation

## ◆ getMean()

template<class T , int WINDOW_LENGTH>

T RollingStat< T, WINDOW_LENGTH >::getMean | ( |  | ) | const
| inline

Return the mean of the last WINDOW_LENGTH number of inputs.

Returns
  mean

Definition at line 61 of file RollingStat.h.

## ◆ getStandardDeviation()

template<class T , int WINDOW_LENGTH>

T RollingStat< T, WINDOW_LENGTH >::getStandardDeviation | ( |  | ) | const
| inline

Return the approximate standard deviation of the last WINDOW_LENGTH number of inputs.

Returns
  standard deviation.

Definition at line 78 of file RollingStat.h.

## ◆ getVariance()

template<class T , int WINDOW_LENGTH>

T RollingStat< T, WINDOW_LENGTH >::getVariance | ( |  | ) | const
| inline

Return the approximate variance of the last WINDOW_LENGTH number of inputs.

Returns
  variance

Note
  This should really be calculated using WINDOW_LENGTH-1, but sacrificing accuracy for speed we use the power of two value of WINDOW_LENGTH.

Definition at line 71 of file RollingStat.h.

## ◆ update() [1/2]

template<class T , int WINDOW_LENGTH>

void RollingStat< T, WINDOW_LENGTH >::update | ( | T | x | ) |
| inline

Update the mean and variance given a new input value.

Parameters

  x | the next input value

Note
  timing for unsigned int 10us, int 22us

Definition at line 41 of file RollingStat.h.

## ◆ update() [2/2]

template<class T , int WINDOW_LENGTH>

void RollingStat< T, WINDOW_LENGTH >::update | ( | int8_t | x | ) |
| inline

Update the mean and variance given a new input value.

Parameters

  x | the next input value

Definition at line 51 of file RollingStat.h.