|
Boost : |
Subject: Re: [boost] How to generate a Bernuolli number
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-30 23:11:47
AMDG
Barco You wrote:
> I call it 1000 time, and all output is 0.
>
Works for me...
#include <boost/random.hpp>
#include <iostream>
int main() {
double p = 0.5;
boost::mt19937 rng;
boost::bernoulli_distribution<> d(p);
boost::variate_generator<
boost::mt19937&,
boost::bernoulli_distribution<>
> g(rng, d);
for(int i = 0; i < 10; ++i) {
std::cout << g() << std::endl;
}
}
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk