help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] how to seed qrng generators?


From: Kevin Thornton
Subject: Re: [Help-gsl] how to seed qrng generators?
Date: Sun, 12 Jun 2005 03:28:29 -0700 (PDT)

Thanks for the response, but this is not the solution
for the problem.  As I mentioned in my original post,
I tried using the GSL_RNG_SEED environment variable,
which has the same effect as setting the seed
explicitly in the source code(i.e. GSL_RNG_SEED=101
./a.out is equivalent to saying gsl_rng_set(r,101) ). 
These seeding methods only effect the rng generators
(gsl/gsl_rng.h>, and have no effect on the behavior of
the qrng generators (gsl/gsl_qrnh.h>.  Looking at the
library source code revealed that the qrng source
doesn't include any of the rng headers, nor is the
word seed mentioned anywhere.  In addition, some
limited testing shows that the qrng state structs are
not accessible from the calling environment, which
seems to rule out the possibility of direct
manipulation.

Cheers,

Kevin
--- Joakim Hove <address@hidden> wrote:

> Kevin Thornton <address@hidden> writes:
> 
> 
> >   gsl_rng_env_setup();
> >   T = gsl_rng_default;
> >   r = gsl_rng_alloc (T);
> 
> Right here you put in a call:
> 
>     gsl_rng_set(r , seed);
> 
> If you do not call this routine explicitly the
> generator is seeded
> wtih a default seed. To actually get a seed you can
> (at linux at
> least) use /dev/random:
> 
> 
>   unsigned int seed;
>   FILE *dev_random;
> 
>   dev_random = fopen("/dev/random","r");
>   if (dev_random == NULL) {
>     fprintf(stderr,"Can not open /dev/random -
> seeding failed\n");
>     seed = 0;
>   } else {
>     fread(&seed , sizeof(seed), 1, dev_random);
>     fclose(dev_random);
>   }
> 
> 
> 
> This code (or something very close) has been posted
> here before;
> i.e. I am not the true author of this.
> 
> HTH - Joakim
> 
>  
> 
> 
> -- 
> Joakim Hove
> hove AT ift uib no                 /    
> Tlf: +47 (55 5)8 27 90            /     Stabburveien
> 18             
> Fax: +47 (55 5)8 94 40           /      N-5231
> Paradis                
> http://www.ift.uib.no/~hove/    /             55 91 28 18
> / 92 68 57 04
> 
> 


Kevin Thornton
Committee on Genetics
University of Chicago
http://www.molpopgen.org

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

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