On 12 Apr 2008 at 5:06, pereges wrote:
I came across a code that calculates N uniformly distributed points on
the sphere. z is a random number between -1 and 1 and to calculate it
we use drand48 function which returns a uniformly distributed value
between 0 and 1. What I don't understand is how it actually works ?
What does he actually mean by "uniformly distributed values" ?
An interesting question.
The uniform measure on a finite set X assigns each point measure 1/|X|,
while the uniform measure on a continuous interval [a,b] has a
fairly complicated description - you're really building the Lebesgue
integral.
In this case, there are a couple of sets to consider. First is the
mathematician's interval [0,1] inside the real line. Then there's the
subset X of all those real numbers (each of which is actually rational)
that can be represented in the floating-point system being used. This is
a finite set, but it's hard to conceive of a random number generator
that could produce the uniform measure on X.
A weaker thing to hope would be that if one chooses any interval [a,b]
inside [0,1] with b-a "reasonably" sized (where "reasonable" has some
interpretation in terms of DBL_EPSILON) then as n->infinity, the
proportion of numbers generated that lie inside [a,b] converges to b-a.
Of course, what happens is that the random number generator is entirely
discrete, and its name suggests that it generates integers mod 2^48 and
then maps these to floating point numbers in [0,1]. If the generator is
a good one, then the proportion of outputs equal to any given number mod
2^48 will tend (as the number of iterations -infinity) to 1/2^48.