INNER CODE UNIT · Python
moving_average
matrix-profile-foundation/matrixprofile · matrixprofile/core.py:282
def moving_average(a, window=3):
"""
Computes the moving average over an array given a window size.
Parameters
----------
a : array_like
The array to compute the moving average on.
window : int
The window size.
Returns
-------
The moving average over the array.
"""
return np.mean(rolling_window(a, window), -1)