vendredi 20 mai 2016

Generating numbers with certain probabilities visual basics vba

I have some probabilities of

26% 18% 26% 20% 10%

and I want to generate some numbers (randomly in a certain range) based on the probability groups.

I have done that previously with 2 probabilities of 80% and 20% like below:

If rnd*100 < 80 then Output = 2 
Else  output = 10
End if

But I am not sure how to do that with more than 2 probabilities!




Aucun commentaire:

Enregistrer un commentaire