$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] How to generate a Bernuolli number
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-03-30 09:46:57
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();