|
Boost : |
Subject: Re: [boost] How to generate a Bernuolli number
From: Barco You (barcojie_at_[hidden])
Date: 2009-03-30 20:55:29
Hi Mathias,
I did as you instructed.
double p = 0.5;
boost::mt19937 rng;
boost::bernoulli_distribution<
>
> > d(p);
> boost::variate_generator<
> boost::mt19937&,
> boost::bernoulli_distribution<> > g(rng, d);
>
> double x = g();
But I got always 0 for x, why?
---- Best regards, Barco On Mon, Mar 30, 2009 at 9:46 PM, Mathias Gaunard < mathias.gaunard_at_[hidden]> wrote: > 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(); > > _______________________________________________ > Unsubscribe & other changes: > http://lists.boost.org/mailman/listinfo.cgi/boost > -- ------------------------------- Enjoy life! Barco You
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk