Quick Navigator

 Search Site Miscellaneous Server Agreement Year 2038 Credits

# Manual Reference Pages  -  MATH::GSL::RANDIST (3)

.ds Aq ’

### NAME

Math::GSL::Randist - Probability Distributions

### SYNOPSIS



use Math::GSL::RNG;
use Math::GSL::Randist qw/:all/;

my $rng = Math::GSL::RNG->new(); my$coinflip = gsl_ran_bernoulli($rng->raw(), .5);  ### DESCRIPTION Here is a list of all the functions included in this module. For all sampling methods, the first argument$r is a raw gsl_rnd structure retrieve by calling raw() on an Math::GSL::RNG object.

#### Logarithmic

 gsl_ran_logarithmic($r,$p) This function returns a random integer from the logarithmic distribution. The probability distribution for logarithmic random variates is, p(k) = {-1 \over \log(1-p)} {(p^k \over k)} for k >= 1. $r is a gsl_rng structure. gsl_ran_logarithmic_pdf($k, $p) This function computes the probability p($k) of obtaining $k from a logarithmic distribution with probability parameter$p, using the formula given above.

#### Rayleigh

 gsl_ran_rayleigh($r,$sigma) This function returns a random variate from the Rayleigh distribution with scale parameter sigma. The distribution is, p(x) dx = {x \over \sigma^2} \exp(- x^2/(2 \sigma^2)) dx for x > 0. $r is a gsl_rng structure gsl_ran_rayleigh_pdf($x, $sigma) This function computes the probability density p($x) at $x for a Rayleigh distribution with scale parameter sigma, using the formula given above. gsl_ran_rayleigh_tail($r, $a,$sigma) This function returns a random variate from the tail of the Rayleigh distribution with scale parameter $sigma and a lower limit of$a. The distribution is, p(x) dx = {x \over \sigma^2} \exp ((a^2 - x^2) /(2 \sigma^2)) dx for x > a. $r is a gsl_rng structure gsl_ran_rayleigh_tail_pdf($x, $a,$sigma) This function computes the probability density p($x) at$x for a Rayleigh tail distribution with scale parameter $sigma and lower limit$a, using the formula given above.

#### Student-t

 gsl_ran_tdist($r,$nu) This function returns a random variate from the t-distribution. The distribution function is, p(x) dx = {\Gamma((\nu + 1)/2) \over \sqrt{\pi \nu} \Gamma(\nu/2)} (1 + x^2/\nu)^{-(\nu + 1)/2} dx for -\infty < x < +\infty. gsl_ran_tdist_pdf($x,$nu) This function computes the probability density p($x) at$x for a t-distribution with nu degrees of freedom, using the formula given above.

#### Laplace

 gsl_ran_laplace($r,$a) This function returns a random variate from the Laplace distribution with width $a. The distribution is, p(x) dx = {1 \over 2 a} \exp(-|x/a|) dx for -\infty < x < \infty. gsl_ran_laplace_pdf($x, $a) This function computes the probability density p($x) at $x for a Laplace distribution with width$a, using the formula given above.

#### Levy

 gsl_ran_levy($r,$c, $alpha) This function returns a random variate from the Levy symmetric stable distribution with scale$c and exponent $alpha. The symmetric stable probability distribution is defined by a fourier transform, p(x) = {1 \over 2 \pi} \int_{-\infty}^{+\infty} dt \exp(-it x - |c t|^alpha) There is no explicit solution for the form of p(x) and the library does not define a corresponding pdf function. For \alpha = 1 the distribution reduces to the Cauchy distribution. For \alpha = 2 it is a Gaussian distribution with \sigma = \sqrt{2} c. For \alpha < 1 the tails of the distribution become extremely wide. The algorithm only works for 0 < alpha <= 2.$r is a gsl_rng structure gsl_ran_levy_skew($r,$c, $alpha,$beta) This function returns a random variate from the Levy skew stable distribution with scale $c, exponent$alpha and skewness parameter $beta. The skewness parameter must lie in the range [-1,1]. The Levy skew stable probability distribution is defined by a fourier transform, p(x) = {1 \over 2 \pi} \int_{-\infty}^{+\infty} dt \exp(-it x - |c t|^alpha (1-i beta sign(t) tan(pi alpha/2))) When \alpha = 1 the term \tan(\pi \alpha/2) is replaced by -(2/\pi)\log|t|. There is no explicit solution for the form of p(x) and the library does not define a corresponding pdf function. For$alpha = 2 the distribution reduces to a Gaussian distribution with $sigma = sqrt(2)$c and the skewness parameter has no effect. For $alpha < 1 the tails of the distribution become extremely wide. The symmetric distribution corresponds to$beta = 0. The algorithm only works for 0 < $alpha <= 2. The Levy alpha-stable distributions have the property that if N alpha-stable variates are drawn from the distribution p(c, \alpha, \beta) then the sum Y = X_1 + X_2 + \dots + X_N will also be distributed as an alpha-stable variate, p(N^(1/\alpha) c, \alpha, \beta).$r is a gsl_rng structure

#### Shuffling and Sampling

 gsl_ran_shuffle Please use the shuffle method in the GSL::RNG module OO interface. gsl_ran_choose Please use the choose method in the GSL::RNG module OO interface. gsl_ran_sample Please use the sample method in the GSL::RNG module OO interface. gsl_ran_discrete_preproc gsl_ran_discrete($r,$g) After gsl_ran_discrete_preproc has been called, you use this function to get the discrete random numbers. $r is a gsl_rng structure and$g is a gsl_ran_discrete structure gsl_ran_discrete_pdf($k,$g) Returns the probability P[$k] of observing the variable$k. Since P[$k] is not stored as part of the lookup table, it must be recomputed; this computation takes O(K), so if K is large and you care about the original array P[$k] used to create the lookup table, then you should just keep this original array P[$k] around.$r is a gsl_rng structure and $g is a gsl_ran_discrete structure gsl_ran_discrete_free($g) De-allocates the gsl_ran_discrete pointed to by g.


You have to add the functions you want to use inside the qw /put_funtion_here /.
You can also write use Math::GSL::Randist qw/:all/; to use all avaible functions of the module.
Other tags are also avaible, here is a complete list of all tags for this module :


logarithmic
choose
exponential
gumbel1
exppow
sample
logistic
gaussian
poisson
binomial
fdist
chisq
gamma
hypergeometric
dirichlet
negative
flat
geometric
discrete
tdist
ugaussian
rayleigh
dir
pascal
gumbel2
shuffle
landau
bernoulli
weibull
multinomial
beta
lognormal
laplace
erlang
cauchy
levy
bivariate
pareto


For example the beta tag contains theses functions : gsl_ran_beta, gsl_ran_beta_pdf.



For more informations on the functions, we refer you to the GSL offcial documentation: <http://www.gnu.org/software/gsl/manual/html_node/>



You might also want to write

use Math::GSL::RNG qw/:all/;



since a lot of the functions of Math::GSL::Randist take as argument a structure that is created by Math::GSL::RNG. Refer to Math::GSL::RNG documentation to see how to create such a structure.

Math::GSL::CDF also contains a structure named gsl_ran_discrete_t. An example is given in the EXAMPLES part on how to use the function related to this structure.

### EXAMPLES



use Math::GSL::Randist qw/:all/;
print gsl_ran_exponential_pdf(5,2) . "\n";

use Math::GSL::Randist qw/:all/;
my \$x = Math::GSL::gsl_ran_discrete_t::new;



### AUTHORS

Jonathan Duke Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>