18 Aug
2009
18 Aug
'09
2:52 a.m.
AMDG er wrote:
It's called discrete_distribution in the new standard. Also, the alias algorithm is more efficient. See attached. (Note that I haven't tried to make this implementation numerically bulletproof.)
discrete does not sort the weights, so this step has to be carried out beforehand to get a comparable basis. I've added a small test file to compare categorical and discrete, where discrete is 10x faster than categorical at initialization and is equally fast at sampling.
Your test isn't quite right. You're comparing the speed of categorical to itself for sampling. In Christ, Steven Watanabe