I am using the numpy random number generator with the following MWE:
import numpy as np
np.random.seed(40)
print(np.random.randint(-3, 4))
rng = np.random.default_rng(seed=40)
print(rng.integers(-3, 4))
This outputs:
3
0
Why are the outputs different?
numpy.random.randintandnumpy.random.seeduse the old random API, with an entirely different implementation under the hood.numpy.random.default_rngcreates a Generator object, which is the new API.The two APIs are effectively two entirely separate RNG libraries that happen to live in the same namespace. Output isn't expected to match, even with the same seed.