简体   繁体   中英

How a random number is generated in Numpy if I don't use Generator or RandomState?

I have read the Doc of Numpy,but I still don't know how a random number is generated if I don't use Generator or RandomState. As far as I know,we can get a random number from 1 to 10 by

#use RandomState
print(np.random.RandomState().randint(1,10,(1)))
#use Generator
print(np.random.default_rng().randint(1,10,(1)))
#my question
print(np.random.default_rng().integers(1,10,(1)))

So how the random number is generated in the third way?

(This targets the first version of the question)

There is just a RandomState created globally at start/import/load-time.

See code

More to read in this discussion: Public access to global state for numpy.random

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM