GSL::Rng.new(rng_type[, seed])
This method returns a GSL::Rng object of a random number generator of type
rng_type with a seed seed. These two arguments can be omitted,
and the generator 'gsl_rng_mt19937' and a seed 0 are used as defaults.
The GSL library provides a number of random number generator types,
and one can choose with a constant GSL::RNG_xxx
or a String, as
GSL::Rng::MT19937
or "gsl_rng_mt19937"
or "mt19937"
GSL::Rng::RANLXS0
or "gsl_rng_ranlsx0"
or "ranlxs0"
GSL::Rng::ZUF
or "gsl_rng_zuf"
or "zuf"
See the GSL reference manual for the complete list. The following demonstrates how to use this class,
require 'gsl' r = Rng.new(Rng::TAUS, 1) r2 = Rng.new("ran0", 2) p r.name <- "taus" p r.get <- get an integer p r2.uniform <- get a float of [0, 1)
A generator of the type gsl_rng_taus is created with seed 1, and gsl_rng_ran0 with seed 2. The method get returns a random integer. The method uniform returns a floating number uniformly distributed in the range [0, 1).
If the package rngextra is installed, additional two generators are available,
GSL::Rng::RNGEXTRA_RNG1
, "rngextra_rng1"
GSL::Rng::RNGEXTRA_RNG2
, "rngextra_rng2"
They are created as
r1 = Rng.new(Rng::RNGEXTRA_RNG1) p r1.name <- "rng1" r2 = Rng.new("rngextra_rng2") p r2.name <- "rng2"
GSL::Rng.default_seed
GSL::Rng.set_default_seed(seed)
GSL::Rng.default_seed=(seed)
GSL::Rng.env_setup()
GSL::Rng.types_setup()
GSK::Rng.memcpy(dest, src)
GSL::Rng#set(s)
GSL::Rng#get
GSL::Rng#uniform
GSL::Rng#uniform_pos
GSL::Rng#uniform_int(n)
GSL::Rng#name
GSL::Rng#max
GSL::Rng#min
GSL::Rng#clone
GSL::Rng#duplicate