23 Nov 2010 23 Nov '10
Can you compare the speed of your cython solution with the version of Chuck
For multiple samples of the same distribution, it would do more or less the same as the "searchsorted" method, so I don't expect any improvement (except for being easier to find).
For multiple samples of different distributions, my version is 4-5x faster than "searchsorted(random())". This is without normalizing the probability vector, which means that you typically don't have to sum up the whole vector (and store all the intermediate sums).