Random Number Generators¶
This chapter introduces the random number generator type provided by .
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 to get the name of the rng used internally.
Methods of this type 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.
rngstring
typenamme r This base class can be instantiated by its
name
import pygsl.rng
my_ran0=pygsl.rng.ran0()
.
The type of the allocated generator is given by the method
name which returns its name as string.
All generators can be seeded with
setseed 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_intupper 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, is raised.
Furthermore a lot of derived probability densities can be used:
gaussiansigma gaussian distribution with mean 0 and given sigma returns float
gaussian_ratio_methodsigma 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_tailsigma, a upper tail of a Gaussian distribution with standard deviation sigma>0. returns float
ugaussian_taila upper tail of a Gaussian distribution with unit standard deviation. returns float
bivariate_gaussiansigma_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)
exponentialmu returns float
laplacemu returns float
exppowmu, a returns float
cauchymu returns float
rayleighsigma returns float
rayleigh_taila, sigma returns float
levymu,a returns float
levy_skewmu,a,beta returns float
gammaa, b returns float
gamma_intlong a returns float
flata, b returns float
lognormalzeta, sigma returns float
chisqnu returns float
fdistnu1, nu2 returns float
tdistnu returns float
betaa, b returns float
logisticmu returns float
paretoa, b returns float
dir_2d returns (float, float)
dir_2d_trig_method returns (float, float)
dir_3d returns (float, float, float)
dir_ndint n returns (float, …, float)
weibullmu, a returns float
gumbel1a, 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 when the is loaded. Here is the list of children from for gsl-1.2: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and .
The default generator of the defaults to rng_mt19937 but can be set from the environment variable using the function .
Probability Density Functions¶
Using probability densities with random number generators¶
This chapter shows you the list of implemented special function and explains details of error handling and return values.
Function list¶
l|ltextttFunctionDescription