ExpandingMean#

Description#

The ExpandingMean function returns the arithmetic mean of every sample seen since the start of the stream (or since the last reset). It is the whole-history analogue of RollingMean and matches pandas.Series.expanding().mean(). Memory is O(1).

Equation:

\[ y[t] = \frac{1}{t+1} \sum_{i=0}^{t} x[i] \]

Parameters: none.

NaN handling#

Policy: ignore. A NaN in the input at index t causes the function to skip that step: output at t is NaN and internal state is unchanged. Subsequent finite samples are processed as if step t had not occurred.

Examples#

Usage example#

import numpy as np
from screamer import ExpandingMean

x = np.arange(1.0, 11.0)
y = ExpandingMean()(x)