[Numpy-discussion] categorical distributions

Hagen Fürstenau hagen at zhuliguan.net
Mon Nov 22 06:05:16 EST 2010


> ISTM that this elementary functionality deserves an implementation
> that's as fast as it can be.

To substantiate this, I just wrote a simple implementation of
"categorical" in "numpy/random/mtrand.pyx" and it's more than 8x faster
than your version for multiple samples of the same distribution and more
than 3x faster than using "multinomial(1, ...)" for multiple samples of
different distributions (each time tested with 1000 samples drawn from
distributions over 1000 categories).

I can provide it as a patch if there's any interest.

- Hagen




More information about the NumPy-Discussion mailing list