running¶
-
running(x, w, /, axis=- 1, pad=True, pad_value=nan)[source]¶ Apply running average to array.
- Parameters
x (array-like) – Data, and we roll along axis
axis.w (int or array-like) – Boxcar window length, or custom weights.
axis (int, optional) – Axis to filter.
pad (bool, optional) – Whether to pad the edges of axis back to original size.
pad_value (float, optional) – The pad value.
- Returns
x (array-like) – Data windowed along axis
axis.
Note
Implementation is similar to
scipy.signal.lfilter. Read this post.Generates rolling numpy window along final axis. Can then operate with functions like polyfit or mean along the new last axis of output. Note this creates view of original array, without duplicating data, so no worries about efficiency.