seed for pseudiorandom generator
Hello, I'm updating some algorithms and I need a tip for initialisation of the boost mersenne twister. I think the ctime is not a very good initialization. I think about a uuid value of the OS. I use also the non-deterministic generator, but I need an idea for the mersenne twister initialization. Do you have an idea? Thanks Phil
I think I've used boost.chrono before to get a seed but I can't find the code right now. I think I just got the result of the now() of the most precise clock and converted it to some usable value as seed. Did you try something like this? Joel Lamotte
I'm satisfied with the random generators, but I don't know how to choose a good initialization value !? Phil Am 26.08.2012 um 00:40 schrieb Júlio Hoffimann:
Why aren't you satisfied with all those mentioned alternatives?
Regards, Júlio. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Sorry, i didn't understood yet. Are you saying you aren't using the boost::random::mt19937 specialization? Because it's there just for people who don't have the background to choose an appropriate parametrization (like me who don't have a PhD on random generators). typedef mersenne_twister_engine http://www.boost.org/doc/libs/1_51_0/doc/html/boost/random/mersenne_twister_...< uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1812433253 > mt19937; The last statement at this section: http://www.boost.org/doc/libs/1_51_0/doc/html/boost_random/reference.html#bo... Regards, Júlio.
Am 26.08.2012 um 14:18 schrieb Júlio Hoffimann:
Sorry, i didn't understood yet.
Are you saying you aren't using the boost::random::mt19937 specialization? Because it's there just for people who don't have the background to choose an appropriate parametrization (like me who don't have a PhD on random generators). typedef mersenne_twister_engine< uint32_t, 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1812433253 > mt19937;
The last statement at this section: http://www.boost.org/doc/libs/1_51_0/doc/html/boost_random/reference.html#bo...
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? Phil
Understood, but this is just an initial value for the pseudo-random sequence, right? Why are you trying to choose a "better" initial value? It doesn't matter as long as it's different every time you start your program. (static variable) That's the point of a random generator, there is no formula or guess for the seed, unless you want intentionally reproduce some output for debug purposes. Regards, Júlio.
AMDG On 08/25/2012 03:17 PM, Kraus Philipp wrote:
Hello,
I'm updating some algorithms and I need a tip for initialisation of the boost mersenne twister. I think the ctime is not a very good initialization. I think about a uuid value of the OS. I use also the non-deterministic generator, but I need an idea for the mersenne twister initialization.
Do you have an idea?
Well, you can use random_device to get a seed:
random_device rng;
mt19937 prgn1(rng()); // seed with one random value
std::vector
participants (4)
-
Júlio Hoffimann
-
Klaim - Joël Lamotte
-
Kraus Philipp
-
Steven Watanabe