help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Seed for RNG


From: Tommy Nordgren
Subject: Re: [Help-gsl] Seed for RNG
Date: Sat, 1 Mar 2008 14:39:28 +0100


On 29 feb 2008, at 15.40, Daniel J Farrell wrote:

Yeah,

Like this,

gsl_rng_set(rng, time(NULL));
        I think it's possible to improve this a lttle further:
   gsl_rng_set(rng, time(NULL) + MULTIPLIER * clock() % DIVISOR);
        Where MULTIPLIER and DIVISOR are suitable constants.
        (The routine clock() returns the cpu time consumed since the start
of the current process in suitable units (Microseconds on Mac OS X))
        This modification will prevent two random numbers allocated within
a short time interval from having the same seed.


you will also need to include the header file for time(), it think it is,

#include <sys/types.h>

and

#include <time.h>


Cheers,

Dan.

On 28 Feb 2008, at 18:57, Tommy Nordgren wrote:


On 28 feb 2008, at 19.40, Johan van der Walt wrote:

I got my little code going for generating random numbers using the GSL routines. Works fine. I now want to use a different seed every time I run the code. But I don't want to enter a new seed on the command line like this
  $ GSL_RNG_TYPE="taus" GSL_RNG_SEED=123 ./a.out
every time I run the code.

How can I set the seed in the code?

Johan

        Use the computer clock to generate the seed.

-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
address@hidden






_______________________________________________
Help-gsl mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-gsl


-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
address@hidden








reply via email to

[Prev in Thread] Current Thread [Next in Thread]