mercredi 19 janvier 2022

Python - passing random seed (generator) to `randn()`

I was reading this blog post and they suggest that rather than setting the random seed for the whole document

np.random.seed(1234)
x = np.random.randn(100)

One should use a generator, which can be created as such

rng = np.random.default_rng(1234)

In the post they use the example of rng.rand(10) which works fine. I need to use randn() however and it doesn't work if you use rng.randn(10).




Aucun commentaire:

Enregistrer un commentaire