I'm looking into using the gsl library random number generators...

The program I have at hand produces uniform random numbers in the range [0.0, 1.0),

Code:

#include <stdio.h>
#include <gsl/gsl_rng.h>
int
main (void)
{
const gsl_rng_type * T;
gsl_rng * r;
int i, n = 10;
gsl_rng_env_setup();
T = gsl_rng_default;
r = gsl_rng_alloc (T);
for (i = 0; i < n; i++)
{
double u = gsl_rng_uniform (r);
printf ("%.5f\n", u);
}
gsl_rng_free (r);
return 0;
}

this code outputs:

$ ./a.out

0.99974

0.16291

0.28262

0.94720

0.23166

0.48497

0.95748

0.74431

0.54004

0.73995

in this particular case.

How can I modify it so it can generate random numbers based on gaussian distribution? ( I don't know enough to decipher the code above in parts)

double gsl_ran_gaussian (const gsl_rng * r, double sigma)

"This function returns a Gaussian random variate, with mean zero and standard deviation sigma. The probability distribution for Gaussian random variates is,

p(x) dx = {1 \over \sqrt{2 \pi \sigma^2}} \exp (-x^2 / 2\sigma^2) dx

for x in the range -\infty to +\infty. Use the transformation z = \mu + x on the numbers returned by gsl_ran_gaussian to obtain a Gaussian distribution with mean \mu. This function uses the Box-Mueller algorithm which requires two calls to the random number generator r. "