vendredi 28 avril 2017

Choose index of numpy matrix with regard to vector of probabilities

Given an n x n (stochastic) Numpy array A and another Numpy array p in [0,1]^n. For each row A_i of A, I want to compute the smallest index j* such that p_i <= A_i,j*.

How can I implement this efficiently in Numpy? I guess this can somehow be done with numpy.random.choice.




Aucun commentaire:

Enregistrer un commentaire