1. ## working of drand48()

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 ? I see that in this function it has been called twice which would mean it return two different values each time. Wouldn't this lead to a wrong result ? I think what we can do is call it only once and store the random value in a variable and then use it in calculations. what do you think ?

Code:
```void SpherePoints(int n, double X[], double Y[], double Z[])
{
int i;
double x, y, z, w, t;

for( i=0; i< n; i++ ) {
z = 2.0 * drand48() - 1.0;
t = 2.0 * M_PI * drand48();
w = sqrt( 1 - z*z );
x = w * cos( t );
y = w * sin( t );
printf("i=%d:  x,y,z=\t%10.5lf\t%10.5lf\t%10.5lf\n", i, x,y,z);
X[i] = x; Y[i] = y; Z[i] = z;
}
}```

2. This is the Box-Muller method of generating numbers from a normal distribution from two(!) uniform random numbers.