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.
I have a short tutorial describing how to do that here:
https://ericlippert.com/2012/02/21/generating-random-non-uniform-data/
Summary:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With