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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With