jeudi 22 juin 2017

random number with an expected average without loops

Given a uniform random number generator that works in O(1), generating a random floating point number on the interval [0..1), how could I generate a random integer on a range [a..b] where a and b are integers, and I expect the average value generated over a large number of iterations to be c, where c is a floating point number on the interval (a..b)?

I've looked over similar questions already on StackOverflow, such as this, this, and this, but they seem to each have a different focus than what I am after.




Aucun commentaire:

Enregistrer un commentaire