13 April 2016

Rando

John D. Cook alerts us to a pitfall in seeding a random number generator (RNG) for multiple processes/threads (for instance, for a Monte Carlo simulation):
Applying the analog of the birthday problem to the RNG seeds explains why the project was launching processes with the same seed. Suppose you seed each process with an unsigned 16-bit integer. That means there are 65,536 possible seeds. Now suppose you launch 1,000 processes. With 65 times as many possible seeds as processes, surely every process should get its own seed, right? Not at all. There’s a 99.95% chance that two processes will have the same seed.