Simple test code:
pop = numpy.arange(20)
rng = numpy.random.default_rng(1)
rng.choice(pop,p=numpy.repeat(1/len(pop),len(pop))) # yields 10
rng = numpy.random.default_rng(1)
rng.choice(pop) # yields 9
The numpy documentation says:
The probabilities associated with each entry in a. If not given the sample assumes a uniform distribution over all entries in a.
I don't know of any other way to create a uniform distribution, but numpy.repeat(1/len(pop),len(pop))
.
Is numpy using something else? Why?
If not, how does setting the distribution affects the seed?
Shouldn't the distribution and the seed be independent?
What am I missing here?
Aucun commentaire:
Enregistrer un commentaire