jeudi 25 avril 2019

how to generate a random number with a known probability?

I would like to generate a random number between x and y with a known probability. For example, using Output=randint(0,2) i know that there is a 33% probability that Output is equal to 1.

Similarly, if Output=randint(0,3) i know that there is 25% probability that the Output is equal to 1.

How can i generate a random number similar to above to make sure that there is 40% probability that Output equal to 1?

Thanks a lot




Aucun commentaire:

Enregistrer un commentaire