Python multiple random seeds

numpy, python, random

Solution

You can use several different `np.random.RandomState`s and call the methods on those:

import numpy as np

rng1 = np.random.RandomState(100)
rng2 = np.random.RandomState(100)

print(rng1.randint(0, 100, 1))  # [8]
print(rng2.randint(0, 100, 1))  # [8]

I used the same seed (`100`) for both, because it shows that both give the same results.

Problem

Is there any way to use two different seeds for numpy random number generator in a python code, one to be used for part of the code, and the other for the rest of the code?

Original source

Related problems