help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] how to seed qrng generators?


From: Kevin Thornton
Subject: [Help-gsl] how to seed qrng generators?
Date: Fri, 10 Jun 2005 08:08:26 -0700 (PDT)

Hi--

I'm trying to use the quasi-random sequence
generators, and I've been unable to figure out how to
seed them.  I've tried using the GSL_RNG_SEED
environment variable, which has had no effect.  I'm
working with the following example code for the
moment, and any advice would be appreciated:

#include<stdlib.h>
#include<stdio.h>
#include <gsl/gsl_qrng.h>
#include <gsl/gsl_rng.h>

int main(int argc, char **argv)
{  
  gsl_qrng * q;
  double priors[2];
  int i;
  gsl_rng * r;
  const gsl_rng_type * T;

  gsl_rng_env_setup();
  T = gsl_rng_default;
  r = gsl_rng_alloc (T);

  printf ("generator type: %s\n", gsl_rng_name (r));
  printf ("seed = %lu\n", gsl_rng_default_seed);
  printf ("first value = %lu\n", gsl_rng_get (r));
  q = gsl_qrng_alloc (gsl_qrng_sobol, 2);

  /* try setting to some initial value? */
  priors[0] = gsl_rng_uniform(r);
  priors[1] = gsl_rng_uniform(r);
  fprintf(stdout,"%f %f\n",priors[0],priors[1]);
  for(i=0;i<10;++i)
    {
      gsl_qrng_get(q,priors);
      fprintf(stdout,"%f %f\n",priors[0],priors[1]);
    }
}

Thanks,

Kevin

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


                
__________________________________ 
Discover Yahoo! 
Find restaurants, movies, travel and more fun for the weekend. Check it out! 
http://discover.yahoo.com/weekend.html 





reply via email to

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