In my program I need to run N separate threads each with their own RNG which is used to sample a large dataset. I need to be able to seed this entire process with a single value so I can reproduce results.
Is it sufficient to simply sequentially increase the seed for each index?
Currently I use numpy
's RandomState
which uses a Mersenne Twister pseudo-random number generator.
Snippet of code below:
# If a random number generator seed exists
if self.random_generator_seed:
# Create a new random number generator for this instance based on its
# own index
self.random_generator_seed += instance_index
self.random_number_generator = RandomState(self.random_generator_seed)
Essentially I start off with a user-inputted seed (if it exists) and for each instance / thread I sequentially add the index (0 to N-1) of the instance running. I don't know if this is good practice or if there's a better way of doing this.