I have a exactly sorted numpy array like this:
arr = np.asarray([1351.1, 1351.11, 1351.14, 1351.16])
and I have a value array also exactly sorted value like this:
vs = np.asarray([1351.10, 1351.13, 1351.17])
I want to find the last index of value in arr is less than or equal to vs, for example:
vs[0]=1351.10=>arr[0] == v[0]=> output0vs[1]=1351.13=>arr[1] < v[1]andarr[2] > v[1]=> output1vs[2]=1351.17=>arr[3] < v[2]=> output3
so at last output [0, 1, 3]
Of course I can for loop arr, then compare arr with vs, but if arr size is very big, it maybe not a good option.
And I find np.searchsorted, it is not what my want, for example:
np.searchsorted(arr, 1351.13) returns 2, but I want to 1. And also another question, it cannot make use of vs is also sorted.
print([np.searchsorted(arr, x, side='right')-1 for x in vs])