9.1 Random Number Generators

All random number generatores are the same python type (PyGSL_rng), but using the approbriate GSL random generator for generating the random numbers. Use the method name to get the name of the rng used internally.

Methods of this type rng provide the transformation to different probability distributions and give access to basic properties of random number generators. All methods allow to pass one optional integer. Then the method will be evaluated n times and the result will be returned as an array.

@thisclassrng rng@@idxcode<#29

The type of the allocated generator is given by the method
name( )
which returns its name as string.
All generators can be seeded with
set( seed)
which sets the internal seed according to the positive integer seed. Zero as seed has a special meaning, please read details in the gsl reference.
The basic returned number type is integer, these are generated by
get( )
which returns the next number of the pseudo random sequence.
All methods support internal sampling; i.e each method has an optional integer. If given it will return a sample of the approbriate size.
get( |n)
will return the next n numbers of the pseudo random sequence.

Basic information about these numbers can be obtained by

max( )
maximum number of this sequence and
min( )
minimum number of this sequence.
Implemented uniform probability densities are:
uniform( )
returns a real number between $ [0,1)$ .
uniform_pos( )
returns a real number between $ (0,1)$ -- this excludes 0.
uniform_int( upper limit)
returns an integer from 0 to the upper limit (exclusive). If this limit is larger than the number of return values of the underlying generator, pygsl.gsl_Error is raised.
Furthermore a lot of derived probability densities can be used:
gaussian( sigma)
gaussian distribution with mean 0 and given sigma returns float
gaussian_ratio_method( sigma)
gaussian distribution with mean 0 and given sigma. This variate uses the Kinderman-Monahan ratio method. returns float
ugaussian( )
gaussian distribution with unit sigma and mean 0. returns float
ugaussian_ratio_method( )
gaussian distribution with unit sigma and mean 0. This variate uses the Kinderman-Monahan ratio method. returns float
gaussian_tail( sigma, a)
upper tail of a Gaussian distribution with standard deviation sigma>0. returns float
ugaussian_tail( a)
upper tail of a Gaussian distribution with unit standard deviation. returns float
bivariate_gaussian( sigma_x, sigma_y, rho)
pair of correlated gaussian variates, with mean zero, correlation coefficient rho and standard deviations sigma_x and sigma_y in the x and y directions returns  (float,float)
exponential( mu)
returns float
laplace( mu)
returns float
exppow( mu, a)
returns float
cauchy( mu)
returns float
rayleigh( sigma)
returns float
rayleigh_tail( a, sigma)
returns float
levy( mu,a)
returns float
levy_skew( mu,a,beta)
returns float
gamma( a, b)
returns float
gamma_int( long a)
returns float
flat( a, b)
returns float
lognormal( zeta, sigma)
returns float
chisq( nu)
returns float
fdist( nu1, nu2)
returns float
tdist( nu)
returns float
beta( a, b)
returns float
logistic( mu)
returns float
pareto( a, b)
returns float
dir_2d( )
returns (float, float)
dir_2d_trig_method( )
returns (float, float)
dir_3d( )
returns (float, float, float)
dir_nd( int n)
returns (float, ..., float)
weibull( mu, a)
returns float
gumbel1( a, b)
returns float
gumbel2( )
poisson( )
bernoulli( )
binomial( )
negative_binomial( )
pascal( )
geometric( )
hypergeometric( )
logarithmic( )
landau( )
erlang( )

The different generator classes are created according to the output of gsl_rng_types_setup() when the pygsl.rng is loaded. Here is the list of children from rng for gsl-1.2:
rng_borosh13, rng_coveyou, rng_cmrg, rng_fishman18, rng_fishman20, rng_fishman2x, rng_gfsr4, rng_knuthran, rng_knuthran2, rng_lecuyer21, rng_minstd, rng_mrg, rng_mt19937, rng_mt19937_1999, rng_mt19937_1998, rng_r250, rng_ran0, rng_ran1, rng_ran2, rng_ran3, rng_rand, rng_rand48, rng_random128_bsd, rng_random128_glibc2, rng_random128_libc5, rng_random256_bsd, rng_random256_glibc2, rng_random256_libc5, rng_random32_bsd, rng_random32_glibc2, rng_random32_libc5, rng_random64_bsd, rng_random64_glibc2, rng_random64_libc5, rng_random8_bsd, rng_random8_glibc2, rng_random8_libc5, rng_random_bsd, rng_random_glibc2, rng_random_libc5, rng_randu, rng_ranf, rng_ranlux, rng_ranlux389, rng_ranlxd1, rng_ranlxd2, rng_ranlxs0, rng_ranlxs1, rng_ranlxs2, rng_ranmar, rng_slatec, rng_taus, rng_taus2, rng_taus113, rng_transputer, rng_tt800, rng_uni, rng_uni32, rng_vax, rng_waterman14, and rng_zuf.

The default generator of the rng defaults to rng_mt19937 but can be set from the environment variable GSL_RNG_TYPE using the function rng.env_setup().