I have a list of numbers and another list of probabilities which corresponds to these numbers. I use numpy.random.choice
to create a random 2d array:
choice = numpy.random.choice([10, 22, 30], [10, 10], p=[0.45, 0.45, 0.10])
In choice
should be 45 ones, 45 twos and 10 zeros but after several runs i never get the correct distribution.
unique, counts = numpy.unique(choice, return_counts=True)
print(dict(zip(unique, counts)))
{10: 49, 22: 37, 30: 14}
{10: 47, 22: 42, 30: 11}
{10: 40, 22: 51, 30: 9}
What did i miss?
Aucun commentaire:
Enregistrer un commentaire