This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Monte Carlo in GSL


Przemyslaw Sliwa wrote:

Dear All,

I am planning to do a Monte Carlo simulation using the GSL random number
generators. Therefore I would like to ask you something:

I have to simulate a function of one variable. This is a stochastic
process. Therefore I have to use the random number generator
gsl_ran_gaussian (const gsl_rng * r, double sigma).

Additionally I have to solve certain nonlinear equation which depends on
one variable and the nonlinear function is a stochastic process mentioned
above. Therefore I have to simulate the value of this functio couple of
times.

The question is: Do I have to execute the statement

gsl_rng_env_setup();

 T = gsl_rng_default;
 r = gsl_rng_alloc (T);

each time I compute the value of my function or just once at the beginning
of the process where I solve the equation.



You have to do this only at the beginning of you program

My problem is: I want that the random numbers I generate are purelly
random and not that the series of the numbers repeats.



On a computer this is impossible but, you can use computer time function
to inizialize every time with a different seed.

for example

time_t T;
R = gsl_rng_alloc (gsl_rng_mt19937);
S = (unsigned) time(&T);
gsl_rng_set (R,S);

Thanks a lot for your help,

Przemyslaw




Claudio

--
==========================================================
Claudio Attaccalite
PhD student in Condensed Matter Theory
S.I.S.S.A.
Via Beirut 2-4 34014 Grignano (TS)
email: attacc@sissa.it
ICQ number: 23970278
web site: www.freescience.info
=========================================================== A quart of ale is a dish for a king. -William Shakespeare Winter's Tale




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]