Consider the following code:
Current solution:
import numpy as np y_i=np.linspace(0,1,11) #0,0.1,0.2,...,1 y=np.random.uniform(0,1) #random point in [0,1) i=np.argmax(y_i>=y) #returns the index of the smallest number in y_i greater than or equal to yIf
y
is an array of random points, and one would like to attain all the indices in y_i
for each of these points, how would one go about doing that using np.argmax or any other one-liner if it exists?Current solution:
d=2 y=np.random.uniform(0,1,d) i=np.zeros(d) for l in range(0,d): i[l]=np.argmax(y_i>=y[l])