Given a random number generator r() which produces a (pseudo-)random double in the interval [0,1] with uniform density, ie p(x) = 1 for 0 <= x <= 1 and p(x) = 0 elsewhere, create a random number generator r(a,b) which generates a double in the interval [a,b] with density p(x) = 1/(b-a) for a <= x <= b.
Given a random number generator r() which produces a (pseudo-)random double in the interval
Share
I believe (and have tested) that this produces a uniform distribution.
but is there another more obvious way?
Yes: