I'm vectorizing a bunch of stuff, and some of the code is based on the random
library (there is no need for security or anything special here, just basic pseudo-randomness). Naturally I move things to numpy.random
, but unfortunately
import numpy.random as nr
import random as r
r.seed(4293061225)
nr.seed(4293061225)
print([r.randint(0, 9) for _ in range(10)]) # Tried also with randrange(10) to make sure they yield the same order of numbers
nr.randint(10, size=10) # Tried looping one by one, to make sure the size thing makes no difference
yields different numbers:
[4, 0, 2, 0, 5, 0, 8, 6, 9, 2]
array([0, 1, 8, 2, 2, 5, 3, 5, 3, 7])
I thought both libraries used Mersenne Twister, and as such would yield the same numbers. Is there an easy way to achieve this (without generating the numbers on one implementation and using the same in the other)?
Aucun commentaire:
Enregistrer un commentaire