Boost 1.43 seems to support binomial distributions . You can use boost::variate_generator to connect the random source to the type you want to select.
So, your code might look something like this (Disclaimer: Unverified!):
boost::mt19937 rng; // produces randomness out of thin air // see pseudo-random number generators const int n = 20; const double p = 0.5; boost::binomial<> my_binomial(n,p); // binomial distribution with n=20, p=0.5 // see random number distributions boost::variate_generator<boost::mt19937&, boost::binomial<> > next_value(rng, my_binomial); // glues randomness with mapping int x = next_value(); // simulate flipping a fair coin 20 times
source share