I want to select m random numbers from a list whom items have different probabilities. How can I do this? For example I have this list:
list = [0,1,2,3,4,5,6]
and its items have these probabilities to be selected (shown below), respectively:
prob = [0.3,0.1,0.2,0.05,0.15,0.1,0.1]
So, 0 is more likely to be selected and then 2 and so on.
I want something like this code to select m random numbers from list depend on p:
random.choices(list, p = prob , k = m)
which p is an argument for getting probabilities and k is number of selected number.
Aucun commentaire:
Enregistrer un commentaire