I have a 2-D Numpy array P where each P[ii,:] is a discrete probability distribution over 0,1,...,M-1. I would like to sample from each of the P[ii,:]'s once. I've tried to use the numpy.random.choice function:
for ii in range(N):
samples[ii] = np.random.choice(np.arange(M), p=P[ii,:])
How can I do the same thing without for loop?
Thank you.