Next: Sampling from a random number generator, Previous: The Random Number Generator Interface, Up: Random Number Generation
This function returns a pointer to a newly-created instance of a random number generator of type T. For example, the following code creates an instance of the Tausworthe generator,
gsl_rng * r = gsl_rng_alloc (gsl_rng_taus);If there is insufficient memory to create the generator then the function returns a null pointer and the error handler is invoked with an error code of
GSL_ENOMEM
.The generator is automatically initialized with the default seed,
gsl_rng_default_seed
. This is zero by default but can be changed either directly or by using the environment variableGSL_RNG_SEED
(see Random number environment variables).The details of the available generator types are described later in this chapter.
This function initializes (or `seeds') the random number generator. If the generator is seeded with the same value of s on two different runs, the same stream of random numbers will be generated by successive calls to the routines below. If different values of s are supplied, then the generated streams of random numbers should be completely different. If the seed s is zero then the standard seed from the original implementation is used instead. For example, the original Fortran source code for the
ranlux
generator used a seed of 314159265, and so choosing s equal to zero reproduces this when usinggsl_rng_ranlux
.