mercredi 20 novembre 2019

Random Module with probabilities scenarios [duplicate]

This question already has an answer here:

I have a list with these elements:

list = ["A", "B", "C", "D", "E"]

If i use the random module ex: random.choice (list) it will return a random letter 20 % of the times (notion of probability). However imagine i want to return the letter A more times than the rest of the letters . Imagine the probability of returning the letter A is 60 % and the rest of the letters is 10%.

How can i simulate this situation ?




Aucun commentaire:

Enregistrer un commentaire