I'm trying to perform a "running max-min window" on a numpy array, such that for a given window size, the function returns the distance between the maximum and minimum values for this window.
I would also like to determine the length of each "skip" of the window.
For example:
if x_array = np.array([3,5,1,8,3,5,2,2])
a running window of size 2 and skip lengths of 2 should result in:
[2, 7, 2, 0] since the first window is 3, 5, the second window is 1,8 etc.
Surely it can be done using a simple for-loop, but I'm struggling with thinking of better solutions.
Any help would be appreciated.
distance between the maximum and minimum values for this window? What islength of each "skip" of the window? You didn't list the final expected output for the given sample.a running window of size 2 and skip lengths of 2 should result in: [2, 7, 2, 0] since the first window is 3, 5, the second window is 1,8 etc.