Boost logo

Boost :

Subject: Re: [boost] How to generate a Bernuolli number
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-30 21:52:46


AMDG

Barco You wrote:
> 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?
>
>

Did you try calling g() multiple times?
The default constructor of boost::mt19937
puts it in a fixed state, so the sequence of
numbers which it generates will always be
the same.

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