lundi 13 janvier 2020

How to use numpy.random to generate random numbers from a certain distribution?

I am somewhat confused about how to use numpy.random to generate random values from a give distribution, say, binomial. I thought it would be

import numpy as np
np.random.binomial(10, 0.3, 5)

However, NumPy reference page shows something like

from numpy.random import default_rng
rg = default_rng()
rg.binomial(10, 0.3, 5)

Both seem to be working well. Which one is the correct or better way? What is the difference if there is any?




Aucun commentaire:

Enregistrer un commentaire