I have a 1D-array representing a time series of size N (with index 0 being the newest value). Now I want to calculate another array that contains a moving maximum, i.e. the maximum of the last M < N values (which would have size N-M+1).
Example (X = time series, Y = desired output with max. of the last 3 values):
X = np.array([5,6,4,5,4,6,5,7,8,9,8])
Y = np.array([6,6,5,6,6,7,8,9,9])
How would I do that efficiently? I've found this thread using numpy's convolve-function to calculate a running average, but I must admit I don't really understand what the convolve does and how to apply it to calculate the running max (or min).