[Numpy-discussion] categorical distributions
Mon Nov 22 01:51:03 CST 2010
numpy doesn't seem to have a function for sampling from simple
categorical distributions. The easiest solution I could come up with was
>>> from numpy.random import multinomial
>>> multinomial(1, [.5, .3, .2]).nonzero()
but this is bound to be inefficient as soon as the vector of
probabilities gets large, especially if you want to draw multiple samples.
Have I overlooked something or should this be added?
More information about the NumPy-Discussion