lundi 9 mars 2020

What is the difference between numpy.random's Generator class and np.random methods?

I have been using numpy's random functionality for a while, by calling methods such as np.random.choice() or np.random.randint() etc. I just now found about the ability to create a default_rng object, or other Generator objects:

from numpy.random import default_rng
gen = default_rng()
random_number = gen.integers(10)

So far I would have always used

np.random.randint(10)

instead, and I am wondering what the difference between both ways is.

The only benefit I can think of would be keeping track of multiple seeds, or wanting to use specific PRNGs, but maybe there are also differences for a more generic use-case?




Aucun commentaire:

Enregistrer un commentaire