I want to create an array that contains all max()es of a window navigating through a given numpy array. Sorry if this sounds confusing. I will give an example. Input data:
[ 6,4,8,7,1,4,3,5,7,2,4,6,2,1,3,5,6,3,4,7,1,9,4,3,2 ]
My output with a window width of 5 will be as follows:
[ 8,8,8,7,7,7,7,7,7,6,6,6,6,6,6,7,7,9,9,9,9 ]
Each number must be a maximum subarray of width 5 of the input array:
[ 6,4,8,7,1,4,3,5,7,2,4,6,2,1,3,5,6,3,4,7,1,9,4,3,2 ]
\ / \ /
\ / \ /
\ / \ /
\ / \ /
[ 8,8,8,7,7,7,7,7,7,6,6,6,6,6,6,7,7,9,9,9,9 ]
I did not find a function out of the box in numpy that would do this (but I would not be surprised if it were like this, I did not always think about the terms that numpy developers thought about). I thought about creating a shifted 2D version of my input:
[ [ 6,4,8,7,1,4,3,5,7,8,4,6,2,1,3,5,6,3,4,7,1 ]
[ 4,8,7,1,4,3,5,7,8,4,6,2,1,3,5,6,3,4,7,1,9 ]
[ 8,7,1,4,3,5,7,8,4,6,2,1,3,5,6,3,4,7,1,9,4 ]
[ 7,1,4,3,5,7,8,4,6,2,1,3,5,6,3,4,7,1,9,4,3 ]
[ 1,4,3,5,7,8,4,6,2,1,3,5,6,3,4,7,1,9,4,3,2 ] ]
np.max(input, 0) . , , ( > 1000000 > 100000 ). .
np.convolve() - , .
, ?