mlnext.score.moving_average#

mlnext.score.moving_average(x: ndarray, step: int = 10, mode='full') ndarray[source]#

Calculates the moving average for X with stepsize step.

Parameters:
  • X (np.ndarray) – 1-dimensional array.

  • step (int, optional) – Stepsize. Defaults to 10.

  • mode (str, optional) – Mode, see np.convolve. Defaults to ‘full’.

Returns:

Returns the moving average.

Return type:

np.ndarray

Example

>>> moving_average(np.array([1, 2, 3, 4]), step=2)
np.ndarray([0.5, 1.5, 2.5, 3.5, 2.])