Boost logo

Boost Users :

Subject: Re: [Boost-users] Random number generation
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-03-08 14:06:32


AMDG

David Kaplan wrote:
> On 8 March 2010 12:39, Diederick C. Niehorster <dcnieho_at_[hidden]> wrote:
>
>> You need to seed the random number generator upon creation, default
>> contructed it will always be in the same state.
>
> Thanks - what's the syntax for doing that?
>

Pass an integer to the constructor or call seed.
The easiest way is

boost::mt19937 gen(std::time(0));

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net