lundi 26 juin 2017

JAVA - How do I generate a random number that is weighted towards certain numbers?

How do I generate a random number in Java, (using Eclipse) that is weighted towards certain numbers?

Example, I have 100 numbers, each can be equally chosen 1% of the time. However, if a certain number, lets say 5, is displayed 8 times in that 100, it now has an 8% chance to be randomly selected, while the other numbers are still at 1%.

How can I write a random generator that gives me 10 numbers and gives the number 5 that 8% advantage to show up?

Thanks and sorry if I did not explain that well.




Aucun commentaire:

Enregistrer un commentaire