Hi,

I am trying to generate gaussian random variables. I am using the following snippet of code to do this. However it gives me the error "undefined reference to ln()". It does the same for ranf(). have included math.h in my header file. It doesnt give me an error for sqrt() because I use the option -lm at command prompt when I compile. This is my first time trying to use these scientific functions. Any help would be appreciated.

Thanks

Code:for(k=0;k<(N+1);k+2) { do { x1 = 2.0 * ranf() - 1.0; x2 = 2.0 * ranf() - 1.0; w = x1 * x2 + x2 * x2; } while(w >= 1.0); w = sqrt((-2.0 * ln(w))/w); x[k] = x1 * w; x[k+1] = x2 * w; }