vendredi 13 octobre 2017

Pick random element from list with probability

I Have a list that contains four item (A, B, C, D). Every item has a probability to be chosen. Let's say for example A has 74% of chance to be picked, B 15%, C 7% ,and D 4%.

I want to create a function that choose randomly an item according to its probability.

Any help please?




Aucun commentaire:

Enregistrer un commentaire