(prob)
return np.argmax(np.random.multinomial(1, prob, 1))
Sample index from probability distribution
Sample index from probability distribution
Sample index from probability distribution
def sample(prob):
    """
    Sample index from probability distribution
    """
    prob = prob / (prob.sum() + 1e-6)
    return np.argmax(np.random.multinomial(1, prob, 1))
def sample ( prob ) : prob = prob / ( prob . sum ( ) + 1e-6 ) return np . argmax ( np . random . multinomial ( 1 , prob , 1 ) )