Why do the numpy and random modules give different random numbers for the same seed?
问题 For the same seed, why does random.random() produce different random values when compared to numpy.random(). My understanding is that they both use the Mersenne Twister to generate random values. import random as rnd import numpy as np rnd.seed(1) np.random.seed(1) rnd.random() np.random.rnd() 0.13436... 0.41702... 回答1: The random module and numpy.random both use a mt19937 to generate random numbers. Because of this, we can copy the state of one from one generator to the other to see if they