Boost logo

Boost Users :

Subject: Re: [Boost-users] Random number generation
From: Diederick C. Niehorster (dcnieho_at_[hidden])
Date: 2010-03-08 05:39:56


Hi David,

You need to seed the random number generator upon creation, default
contructed it will always be in the same state.

Best,
Dee

On Mon, Mar 8, 2010 at 4:29 PM, David Kaplan <davkaplan_at_[hidden]> wrote:
> I'm using the following code to generate a random 64 bit value:
>
> boost::mt19937 rng;
> boost::uniform_int<uint64_t> r(0,0xffffffffffffffff);
> boost::variate_generator<boost::mt19937&, boost::uniform_int<uint64_t> >
> gen(rng, r);
> uint64_t id = gen();
>
> However it seems it's not random on each execution of the program? (rather I
> get the same value again).
> How do I randomise this properly?
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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