Boost logo

Boost Users :

Subject: Re: [Boost-users] seed for pseudo-random generator
From: Neil Nelson (nnelson_at_[hidden])
Date: 2012-08-26 19:32:00


For a little more entropy you can add the seconds from time to the
process PID (UUID). That will give you a difference each run at the
seconds numeric scale that would tend to repeat at the PID cycle rate.
You could add in microseconds from
http://www.boost.org/doc/libs/1_51_0/doc/html/date_time/posix_time.html
(Linux gettimeofday) for additional entropy.

On Linux with some additional work you can use /dev/random and
/dev/urandom (better).

Neil Nelson

> I create within a class the MT object with
>
> static boost::mt19937 m_random;
>
> so I need for a static variable for the initialization value, so I do this with
>
> boost::mt19937 tools::random::m_random( time(NULL) );=
>
> Now: My question is, can I use the time() value for initialization the MT object, so that the MT object returns values with a good entropie or
> should I need another initialization value like a UUID of the OS?
>
> Because the time function (http://www.cplusplus.com/reference/clibrary/ctime/time/ ) returns a time_t value, so is this value good for initialization or should I need another value, if yes, which value if a good choice for
> initialize the MT object?


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