mercredi 9 juin 2021

Why does numpy RandomState gives different results?

I don't understand why

import numpy as np
rng = np.random.RandomState(42)
rng.randint(10, size=1)
np.random.RandomState(rng.randint(10, size=1)).randint(10, size=3)

>>> OUTPUT: array([8, 9, 3])

and

import numpy as np
np.random.RandomState(42).randint(10, size=1)
np.random.RandomState(np.random.RandomState(42).randint(10, size=1)).randint(10,size=3)
>>> OUTPUT: array([9, 3, 4])

Can someone please explain the difference?




Aucun commentaire:

Enregistrer un commentaire