Reputation: 3001
I am doing a scheduling simulation in python which is full determinstic. So, when I have the same input and parameters I always get the same output.
Now I want to randomize the initial starting state of the simulation and compare the output of two (or more) different simulation parameters. To compare the "same randomized initial starting state" I want to set the random.seed()
with an initial value, which should stay the same for all comparisions of different schedulers. Furthermore I want to see the behaviour for one scheduler on different initial states so I have to change the random.seed()
. This I have to do of course for all schedulers.
Now my question is, what impact has the seed on the "randomness" of the random generator? For example does it matter if I choose as a seed 1 or 100? And because I want to use different seeds for the same scheduler and compare it to the other ones, can I simply use e.g. the seeds 1 to 10 or must my seeds be "more random"?
For clarification, I use the random generator for distributing tasks initial on different cores and compare the output to "my optimal (deterministic) initial distribution". I want to get a wide-spread of different distributions with my choosen seeds.
Upvotes: 3
Views: 947
Reputation: 32898
Although your choice of seed doesn't matter in theory, it may matter in practice.
random.seed(integer_seed)
avoids this problem, but if two Mersenne Twister states differ in only one bit, the two sequences they produce will be correlated to each other, and it will take millions of numbers to eliminate this correlation. A similar issue occurs with many other PRNGs, especially linear PRNGs.To reduce the risk of correlated pseudorandom numbers, you can use PRNG algorithms, such as SFC and other so-called "counter-based" PRNGs (Salmon et al., "Parallel Random Numbers: As Easy as 1, 2, 3", 2011), that support independent "streams" of pseudorandom numbers. (Note, however, that PCG has a flawed notion of "streams".) There are other strategies as well, and I explain more about this in "Seeding Multiple Processes". See also this question.
Also, if you're using NumPy (which is a popular Python library for scientific work), note that NumPy 1.17 introduces a new pseudorandom number generation system; it uses so-called bit generators, such as PCG, and random generators, such as the new numpy.random.Generator
. It was the result of a proposal to change the PRNG policy. The NumPy documentation has detailed information on seeding PRNGs in parallel.
Upvotes: 3
Reputation: 338
Your choice of seed shouldn't matter
If the pseduo-random number generator is made correctly then any seed should create a random distribution of numbers.
From Wikipedia:
For a seed to be used in a pseudorandom number generator, it does not need to be random. Because of the nature of number generating algorithms, so long as the original seed is ignored, the rest of the values that the algorithm generates will follow probability distribution in a pseudorandom manner.
Upvotes: 1