vendredi 29 juillet 2016

How to write a random number generator with a weight in C# (or plain math)?

I am trying to write a random number generator function in C# that would take a minimum, maximum, and weight parameters.

With weight == 0, the result would equal minimum, and with weight == 1, the result would equal maximum. With weight == 0.5, all the numbers within the range would have equal chance of being selected.

What I want to achieve is as the weight is approaching the minimum, the minimum has more chances of being selected and the maximum less, and vice versa.




Aucun commentaire:

Enregistrer un commentaire