
AMDG Kevin Martin wrote:
On 16 Aug 2009, at 06:55, er wrote:
Hi, here's something related: https://svn.boost.org/svn/boost/sandbox/statistics/random/boost/random/multi...
I think this is definitely needed in boost::random, and it seems to do much more error checking and dealing with large weights than my version does, so I will definitely change to using it once it makes it into a normal library release (and I can persuade my HPC admin to upgrade the library)
I think you should rename it categorical distribution though as it only samples a single trial from the distribution. I believe the multinomial distribution gives the probability of vectors arising when n trials are performed.
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.) In Christ, Steven Watanabe