GSL-RANDIST¶
This module provides functionality to generate random variates from distributions.
Polymorphism and multimethods were used to simplify the original GSL
library interface, reducing both the function count and the number of
parameters per function. See <gsl-randist> for examples of
this design.
The distributions available in this module are:
The <gsl-randist> interface¶
- <gsl-randist> Abstract Uninstantiable Class¶
Base class for all distributions.
- Init-Keywords:
rng – Random number generator. Used to generate random variates from the distribution. If not provided a new instance of
<gsl-rng>is provided. This generator can be configured by environment variables (see Random number environment variables)
- Operations:
Operations¶
- gsl-randist-variate Generic function¶
- Signature:
gsl-randist-variate distribution => (variate)
Generates a random variate from the distribution.
- Parameters:
distribution – An instance of
<gsl-randist>.
- Result variate:
A random variate from the distribution. An instance of
<float>.
- gsl-randist-pdf Generic function¶
Evaluates the probability density function (PDF) for the distribution.
- Signature:
gsl-randist-pdf (distribution, x) => (pd)
- Parameters:
distribution – An instance of
<gsl-randist>.x – The value at which to evaluate the probability density function. An instance of
<float>.
- Result pd:
The probability density at x. An instance of
<float>.
The Continuous Distribution¶
- <gsl-randist-continuous> Abstract Uninstantiable Class¶
- Superclasses:
Base class for all continuous distributions.
The Continuous distributions available are:
- gsl-randist-cdf-p Generic function¶
Evaluates the cumulative distribution function (CDF) for the distribution.
- Signature:
gsl-randist-cdf-p distribution x => (cd)
- Parameters:
distribution – An instance of
<gsl-randist-continuous>.x – The value at which to evaluate the cumulative distribution function. An instance of
<float>.
- Result cd:
The cumulative probability at x. An instance of
<float>.
- gsl-randist-cdf-q Generic function¶
- Signature:
gsl-randist-cdf-q distribution x => (cd)
- Parameters:
distribution – An instance of
<gsl-randist-continuous>.x – The value at which to evaluate the survival function. An instance of
<float>.
- Result cd:
The survival function at x. An instance of
<float>.
- gsl-randist-cdf-pinv Generic function¶
Evaluates the inverse cumulative distribution function (CDF) for the distribution.
- Signature:
gsl-randist-cdf-pinv distribution x => (cd)
- Parameters:
distribution – An instance of
<gsl-randist-continuous>.x – The value at which to evaluate the inverse cumulative distribution function. An instance of
<float>.
- Result cd:
The inverse cumulative distribution function at x. An instance of
<float>.
- gsl-randist-cdf-qinv Generic function¶
Evaluates the inverse cumulative distribution function (CDF) for the distribution.
- Signature:
gsl-randist-cdf-qinv distribution x => (cd)
- Parameters:
distribution – An instance of
<gsl-randist-continuous>.x – The value at which to evaluate the inverse survival function. An instance of
<float>.
- Result cd:
The inverse survival function at x. An instance of
<float>.
The Gaussian Distribution¶
- <gsl-randist-gaussian> Concrete Instantiable Class¶
A Gaussian distribution. This returns random values of Gaussian probability density function. See the original GSL documentation for more information at Gaussian Distribution. This distribution stores the type of algorithm used to generate random variates.
- Superclasses:
- Init-Keywords:
sigma (required) – Standard deviation. An instance of
<float>.algorithm – The algorithm to use for generating random variates. See Gaussian algorithms for more information.
- Conditions:
A
<gsl-error-invalid-argument>condition is raised if the algorithm is not one of<gaussian-algorithm>.- Example:
let r = make(<gsl-rng>); let d = make(<gsl-randist-gaussian>, sigma: 0.5d0, rng: r); let k = d.gsl-randist-variate;
- Example:
let d = make(<gsl-gaussian>, rng: make(<gsl-rng>), sigma: 0.5d0, algorithm: #"ratio"); let k = d.gsl-randist-variate;
The following operations are defined for
<gsl-randist-gaussian>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-gaussian>) Method¶
- gsl-randist-pdf(<gsl-randist-gaussian>) Method¶
- gsl-randist-cdf-p(<gsl-randist-gaussian>) Method¶
- gsl-randist-cdf-q(<gsl-randist-gaussian>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-gaussian>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-gaussian>) Method¶
The Unit Gaussian distribution¶
- <gsl-randist-ugaussian> Concrete Instantiable Class¶
Unit Gaussian is a Gaussian distribution with sigma = 1.0d0.
- Superclasses:
- Key algorithm:
The algorithm to use for generating random variates. See Gaussian algorithms for more information.
- Discussion:
The keyword
sigma:must not be used since it is initialized by the class.- Example:
let d = make(<gsl-randist-ugaussian>, rng: make(<gsl-rng>)); let v = d.gsl-randist-variate;
- See also:
Gaussian algorithms¶
- <gaussian-algorithm> Class¶
This are the algorithms to generate a Gaussian variate value. This algorithm is passed as an optional keyword
algorithm:to<gsl-randist-gaussian>class. The valid values are:#"box-mullerBox-Muller algorithm. This is the default value.
#"ziggurat"Computes a Gaussian random variate using the alternative Marsaglia-Tsang ziggurat method. The Ziggurat algorithm is the fastest available algorithm in most cases.
#"ratio-method"Kinderman-Monahan-Leva ratio method.
The Gaussian tail distribution¶
- <gsl-randist-gaussian-tail> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
rng (required)
sigma (required)
a (required) – An instance of
<float>. The values returned are larger than this limit, which must be positive.
- Conditions:
A
<gsl-invalid-argument>is signaled ifakeyword is not positive.- Summary:
Provides random variates from the upper tail of a Gaussian distribution with standard deviation
sigma. The values returned are larger than the lower limita, which must be positive.- See also:
The following operations are specialized for
<gsl-randist-gaussian-tail>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-gaussian-tail>) Method¶
- gsl-randist-pdf(<gsl-randist-gaussian-tail>) Method¶
The Ugaussian tail distribution¶
- <gsl-randist-ugaussian-tail> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
rng (required)
a (required) – An instance of
<float>. The values returned are larger than this limit, which must be positive.
- Summary:
Compute results for the tail of a unit Gaussian distribution. They are equivalent to the
<gsl-randist-gaussian-tail>with a standard deviation of one,sigma= 1.0d0.
The Exponential Distribution¶
- <gsl-randist-exponential> Concrete Instantiable Class¶
- Superclasses:
<gsl-randist-continuous>`- Init-Keywords:
mu (required) – Mean mu.
- See also:
The following operations are specialized for
<gsl-randist-exponential>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-exponential>) Method¶
- gsl-randist-pdf(<gsl-randist-exponential>) Method¶
- gsl-randist-cdf-p(<gsl-randist-exponential>) Method¶
- gsl-randist-cdf-q(<gsl-randist-exponential>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-exponential>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-exponential>) Method¶
The Laplace Distribution¶
- <gsl-randist-laplace> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
a (required) – Width
- See also:
The following operations are specialized for
<gsl-randist-laplace>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-laplace>) Method¶
- gsl-randist-pdf(<gsl-randist-laplace>) Method¶
- gsl-randist-cdf-p(<gsl-randist-laplace>) Method¶
- gsl-randist-cdf-q(<gsl-randist-laplace>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-laplace>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-laplace>) Method¶
The Exponential Power Distribution¶
- <gsl-randist-exppow> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
- See also:
The following operations are specialized for
<gsl-randist-exppow>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-exppow>) Method¶
- gsl-randist-pdf(<gsl-randist-exppow>) Method¶
- gsl-randist-cdf-p(<gsl-randist-exppow>) Method¶
- gsl-randist-cdf-q(<gsl-randist-exppow>) Method¶
The Cauchy Distribution¶
- <gsl-randist-cauchy> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
a (required) – Scale parameter. An instance of
<float>
- See also:
The following operations are specialized for
<gsl-randist-cauchy>. See operations in
<gsl-randist-continous> for more information.
- gsl-randist-variate(<gsl-randist-cauchy>) Method¶
- gsl-randist-pdf(<gsl-randist-cauchy>) Method¶
- gsl-randist-cdf-p(<gsl-randist-cauchy>) Method¶
- gsl-randist-cdf-q(<gsl-randist-cauchy>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-cauchy>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-cauchy>) Method¶
The Rayleigh Distribution¶
- <gsl-randist-rayleigh> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
sigma (required) – An instance of
<float>
- See also:
The following operations are specialized for
<gsl-randist-rayleigh>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-rayleigh>) Method¶
- gsl-randist-pdf(<gsl-randist-rayleigh>) Method¶
- gsl-randist-cdf-p(<gsl-randist-rayleigh>) Method¶
- gsl-randist-cdf-q(<gsl-randist-rayleigh>) Method¶
The Rayleigh Tail distribution¶
- <gsl-randist-rayleigh-tail> Class¶
- Superclasses:
- Init-Keywords:
The following operations are specialized for
<gsl-randist-rayleigh-tail>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-rayleigh-tail>) Method¶
- gsl-randist-pdf(<gsl-randist-rayleigh-tail>) Method¶
The Landau distribution¶
- <gsl-randist-landau> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
rng (required)
The following operations are specialized for
<gsl-randist-landau>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-landau>) Method¶
- gsl-randist-pdf(<gsl-randist-landau>) Method¶
The Levy alpha-Stable Distribution¶
- <gsl-randist-levy> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
rng (required)
c (required) – Scale. An instance of
<float>.alpha (required) – Scale. An instance of
<float>.
The following operations are specialized for
<gsl-randist-levy>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-levy>) Method¶
The Levy skew alpha-Stable Distribution¶
- <gsl-randist-levy-skew> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
rng (required)
c (required) – Scale. An instance of
<float>.alpha (required) – Scale. An instance of
<float>.beta (required) – Skew. An instance of
<float>.
The following operations are specialized for
<gsl-randist-levy-skew>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-levy-skew>) Method¶
The Gamma Distribution¶
- <gsl-randist-gamma> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
algorithm – The algorithm to use for generating random variates. See Gamma algorithms for more information.
a (required) – a > 0
b (required) – b > 0
- See also:
The following operations are specialized for
<gsl-randist-gamma>. See operations in <gsl-randist-continuous>
for more information.
- gsl-randist-variate(<gsl-randist-gamma>) Method¶
- gsl-randist-pdf(<gsl-randist-gamma>) Method¶
- gsl-randist-cdf-p(<gsl-randist-gamma>) Method¶
- gsl-randist-cdf-q(<gsl-randist-gamma>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-gamma>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-gamma>) Method¶
Gamma algorithms¶
- <gsl-gamma-algorithm> Class¶
This are the algorithms to generate a Gamma variate value. This algorithm is passed as an optional keyword
algorithm:to<gsl-randist-gaussian>class. The valid values are:#"default"This is the default value.
#"knuth"This function returns a gamma variate using the algorithms from Knuth (vol 2).
The Flat Distribution¶
- <gsl-randist-flat> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
- See also:
- Discussion:
Returns a random variate from the flat (uniform) distribution from a to b
The following operations are specialized for
<gsl-randist-flat>. See operations in <gsl-randist-continuous>
for more information.
- gsl-randist-variate(<gsl-randist-flat>) Method¶
- gsl-randist-pdf(<gsl-randist-flat>) Method¶
- gsl-randist-cdf-p(<gsl-randist-flat>) Method¶
- gsl-randist-cdf-q(<gsl-randist-flat>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-flat>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-flat>) Method¶
The Lognormal Distribution¶
- <gsl-randist-lognormal> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
- See also:
The following operations are specialized for
<gsl-randist-lognormal>. See operations in <gsl-randist-continuous>
for more information.
- gsl-randist-variate(<gsl-randist-lognormal>) Method¶
- gsl-randist-pdf(<gsl-randist-lognormal>) Method¶
- gsl-randist-cdf-p(<gsl-randist-lognormal>) Method¶
- gsl-randist-cdf-q(<gsl-randist-lognormal>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-lognormal>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-lognormal>) Method¶
The Chi-Squared Distribution¶
- <gsl-randist-chisq> Concrete Instantiable Class¶
- Superclasses:
- Init-Keywords:
nu (required) – Degrees of freedom. An instance of
<float>
- Example:
let r = make(<gsl-rng>); let d = make(<gsl-randist-chisq>, nu: 3.0d0, rng: r); let k = d.gsl-randist-variate;
- See also:
The following operations are specialized for
<gsl-randist-chisq>. See operations in
<gsl-randist-continuous> for more information.
- gsl-randist-variate(<gsl-randist-chisq>) Method¶
- gsl-randist-pdf(<gsl-randist-chisq>) Method¶
- gsl-randist-cdf-p(<gsl-randist-chisq>) Method¶
- gsl-randist-cdf-q(<gsl-randist-chisq>) Method¶
- gsl-randist-cdf-pinv(<gsl-randist-chisq>) Method¶
- gsl-randist-cdf-qinv(<gsl-randist-chisq>) Method¶