dimanche 5 septembre 2021

How do you customize probabilities in Java? [duplicate]

If I wanted to randomly sample from an array of strings i.e. {"bob", "turtle", "figs"}, would it be possible to control the probability that each string would be selected?

For example, could I make the probability of "bob" 0.30, probability of "turtle" 0.45 , and probability of "figs" 0.25?

I am familiar with using java.util.Random but only for uniform distributions. Thank you!




Aucun commentaire:

Enregistrer un commentaire