jeudi 28 décembre 2017

Sliding weighted randomization from number range?

When picking a random number from a range, I'm doing rand(0..100). That works all well and good, but I'd like it to favor the lower end of the range.

So, there's the highest probability of picking 0 and the lowest probability of picking 100 (and then everything in between), based on some weighted scale.

How would I implement that in Ruby?




Aucun commentaire:

Enregistrer un commentaire