Jürg W. Spaak
Jürg W. Spaak

Reputation: 2139

Do consequtive RNG seed yield independent random numbers?

I have a script in which I use random simulations. This script runs on a cluster multiple times (about 100). Of course I want the results of each script to be independent from each other, however I also want that the results can be reproduced. Hence I would like to set the seed of the random number generator at the beginning of the script, however this seed of course has to be different in each run on the cluster.

I thought to do it like this:

import sys
import numpy as np
# sys.argv[1] is the number of the job on the cluster
np.random.seed(int(sys.argv[1]))

However this of course gives me consecutive seeds (1,2,3...). Are the random numbers (and in the end) the results of these consecutive seeds random and independent?

Upvotes: 3

Views: 430

Answers (1)

Peter O.
Peter O.

Reputation: 32878

For many PRNG designs, instances initialized with sequential seeds can lead to number sequences with undesirable correlations. This is illustrated in a post on the Unity Blog. To reduce the chance of this problem, those instances should be initialized with unrelated seeds (see also Multiple independent random number streams from single seed).

Upvotes: 4

Related Questions