This question already has an answer here:
Given some list and a list of "biases" in the same order, what would be the best way of picking an item from the list so that it's picked according to the bias?
E.g.
a = [0, 7, 6]
biases = [0.75, 0.125, 0.125] # in same order as a, add to 1
# 0 should be picked 75% of the time, 7 and 6 should both be returned 12.5% of the time
Aucun commentaire:
Enregistrer un commentaire