[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] about the function " gsl_ran_gaussian ( ) "
From: |
Yi Cao |
Subject: |
[Help-gsl] about the function " gsl_ran_gaussian ( ) " |
Date: |
Fri, 8 Apr 2011 19:49:03 -0400 |
Hello everyone,
I am now trying to generate some gauss random numbers (about size of
30,000).
I found the following function in GSL, but I am not clear how to use
this function.
0. can I just call this function in my C++ code?
1. If I use cygwin to compile the C++ code containing the function, can I
just #include"gsl/gsl_randist.h" and then compile it?
2. If I use linux (SUSE), do I have to install the GSL first and then
compile the C++ code?
3.what is the first argument of the function----const gsl_rng *r ? what
value should I assign to it?
Can anyone give me some ideas? Thanks in advance.
------------------------------------------------------------------
double
gsl_ran_gaussian (const gsl_rng * r, const double sigma)
{
double x, y, r2;
do
{
*/* choose x,y in uniform square (-1,-1) to (+1,+1) */*
x = -1 + 2 * gsl_rng_uniform (r);
y = -1 + 2 * gsl_rng_uniform (r);
/* see if it is in the unit circle */
r2 = x * x + y * y;
}
while (r2 > 1.0 || r2 == 0);
*/* Box-Muller transform */*
return sigma * y * sqrt (-2.0 * log (r2) / r2);
}
-----------------------------------------------------------------------------------------------------------------
- [Help-gsl] about the function " gsl_ran_gaussian ( ) ",
Yi Cao <=