14

This is actually not as simple as I first thought.

In the absence of a hardware RNG, what is the best way to seed a Mersenne Twister?

Or should I say, what is an acceptable way to seed a a Mersenne Twister RNG that is used to generate UUID's?

hookenz
  • 30,814
  • 37
  • 149
  • 251
  • google offers http://docstore.mik.ua/orelly/networking/puis/ch23_08.htm – Jim Balter Dec 06 '11 at 04:13
  • 2
    There is a nice discussion of pseudo-random number generators [here](http://www.cs.ucl.ac.uk/staff/d.jones/GoodPracticeRNG.pdf) including a section on proper seed of PRNGs (see rule 3), which uses `md5sum` and `/dev/random` to generate seeds. (This also includes a number of PRNG alogrithms which are a lot easier to code up than the MT but are arguably just as good). – Chris Dec 07 '11 at 23:31
  • @Chris do you want to post that as an answer? I think it's a very good article and is helpful for seeding PRNG in general. – hookenz Dec 11 '11 at 21:28
  • @MattH Added my comment as an answer and elaborated a bit. Thanks for the suggestion. – Chris Dec 12 '11 at 10:42

1 Answers1

8

There is a nice discussion of pseudo-random number generators here including a section on the proper seeding of PRNGs (see rule 3), which uses md5sum and /dev/random or /dev/urandom to generate seeds.

This also includes a number of PRNG alogrithms which are a lot easier to code up (< 10 lines of code) than the MT but are arguably just as good (long periods and pass all of the Dieharder tests for randomness).

Further Reading:

  1. Seed std::mt19937 from std::random_device
  2. Best way to seed mt19937_64 for Monte Carlo simulations
  3. How to obtain (almost) unique system identifier in a cross platform way?
user1032677
  • 313
  • 1
  • 8
Chris
  • 39,262
  • 15
  • 126
  • 145