def sample_from_pvect(pvect):
 onehot_sample = rng.multinomial(n=1, pvals=pvect)
 sample = onehot_sample.argmax()
 return sample

def sample_from_pvect ( pvect ) : onehot_sample = rng . multinomial ( n = 1 , pvals = pvect ) sample = onehot_sample . argmax ( ) return sample
provided utility function: given a symbolic vector of probabilities .