
30 Mar
2009
30 Mar
'09
1:46 p.m.
Barco You wrote:
I want to randomly generate a Bernuolli number [0, 1],with probability p ~[0 1]. How to do that with boost?
From reading the boost.random documentation for a minute, I came up with this: double p = ???; boost::mt19937 rng; boost::bernoulli_distribution<> d(p); boost::variate_generator< boost::mt19937&, boost::bernoulli_distribution<>
g(rng, d);
double x = g();