samedi 13 juin 2020

Get random number with weighted probability [closed]

I want to get random numbers with weighted probabilities. Higher the number, lesser the probability.

For example-
I want to create a method getRandomNumbers() to get random numbers between 0 and 9 (including these numbers). But, 0 must have the highest probability, followed by 1 and 9 must be returned with the least probability i.e. the least number of times.


Code not necessarily required. Anything ranging from algo, to explanation to pseudo code would do the trick.




Aucun commentaire:

Enregistrer un commentaire