|
Boost : |
Subject: Re: [boost] How to generate a Bernuolli number
From: Barco You (barcojie_at_[hidden])
Date: 2009-03-30 22:55:03
Hi Steven,
Thanks for you reply!
I call it 1000 time, and all output is 0.
On Tue, Mar 31, 2009 at 9:52 AM, Steven Watanabe <watanabesj_at_[hidden]>wrote:
> 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
>
>
> _______________________________________________
> 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