Help language development. Donate to The Perl Foundation
Math::Libgsl::RandomDistribution - An interface to libgsl, the Gnu Scientific Library - Random Number Distributions
use Math::Libgsl::Random; use Math::Libgsl::RandomDistribution; my Math::Libgsl::Random $r .= new; say poisson($r, 3) for ^10;
Math::Libgsl::RandomDistribution is an interface to the Random Number Distributions section of libgsl, the Gnu Scientific Library.
This function returns a Gaussian random variate, with mean zero and standard deviation $sigma.
This function computes the probability density at $x for a Gaussian distribution with standard deviation $sigma.
This function computes a Gaussian random variate using the alternative Marsaglia-Tsang ziggurat and Kinderman-Monahan-Leva ratio methods.
These functions compute results for the unit Gaussian distribution. They are equivalent to the functions above with $sigma = 1.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the unit Gaussian distribution.
This function provides random variates from the upper tail of a Gaussian distribution with standard deviation $sigma.
This function computes the probability density p(x) at $x for a Gaussian tail distribution with standard deviation $sigma and lower limit $a.
These functions compute results for the tail of a unit Gaussian distribution.
This function generates a pair of correlated Gaussian variates, with mean zero, correlation coefficient $rho and standard deviations $sigma_x and $sigma_y. The function returns two Num values: the Gauusian correlates along the x and y directions.
This function computes the probability density p(x, y) at ($x, $y) for a bivariate Gaussian distribution with standard deviations $sigma_x, $sigma_y and correlation coefficient $rho.
This function generates a random vector satisfying the k-dimensional multivariate Gaussian distribution with mean μ and variance-covariance matrix Σ. On input, the k-vector μ is given in $mu, and the Cholesky factor of the k-by-k matrix Σ = LT(L) is given in the lower triangle of $L, as output from Math::Libgsl::LinearAlgebra::cholesky-decomp(). The function returns the random vector as a Math::Libgsl::Vector object.
These functions compute p(x) or log p(x) at the point $x, using mean vector $mu and variance-covariance matrix specified by its Cholesky factor $L.
Given a set of n samples Xⱼ from a k-dimensional multivariate Gaussian distribution, this function computes the maximum likelihood estimate of the mean of the distribution. The function returns the maximum likelihood estimate as a Math::Libgsl::Vector object.
Given a set of n samples Xⱼ from a k-dimensional multivariate Gaussian distribution, this function computes the maximum likelihood estimate of the variance-covariance matrix of the distribution. The function returns the maximum likelihood estimate of the variance-covariance matrix as a Math::Libgsl::Matrix object.
This function returns a random variate from the exponential distribution with mean $mu.
This function computes the probability density p(x) at $x for an exponential distribution with mean $mu.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the exponential distribution with mean $mu.
This function returns a random variate from the Laplace distribution with width $a.
This function computes the probability density p(x) at $x for a Laplace distribution with width $a.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Laplace distribution with width $a.
This function returns a random variate from the exponential power distribution with scale parameter $a and exponent $b.
This function computes the probability density p(x) at $x for an exponential power distribution with scale parameter $a and exponent $b.
These functions compute the cumulative distribution functions P(x), Q(x) for the exponential power distribution with parameters $a and $b.
This function returns a random variate from the Cauchy distribution with scale parameter $a.
This function computes the probability density p(x) at $x for a Cauchy distribution with scale parameter $a.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Cauchy distribution with scale parameter $a.
This function returns a random variate from the Rayleigh distribution with scale parameter $sigma.
This function computes the probability density p(x) at $x for a Rayleigh distribution with scale parameter $sigma.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Rayleigh distribution with scale parameter $sigma.
This function returns a random variate from the tail of the Rayleigh distribution with scale parameter $sigma and a lower limit of $a.
This function computes the probability density p(x) at $x for a Rayleigh tail distribution with scale parameter $sigma and lower limit $a.
This function returns a random variate from the Landau distribution.
This function computes the probability density p(x) at $x for the Landau distribution.
This function returns a random variate from the Levy symmetric stable distribution with scale $c and exponent $alpha.
This function returns a random variate from the Levy skew stable distribution with scale $c, exponent $alpha and skewness parameter $beta.
This function returns a random variate from the gamma distribution.
This function returns a gamma variate using the algorithms from Knuth.
This function computes the probability density p(x) at $x for a gamma distribution with parameters $a and $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the gamma distribution with parameters $a and $b.
This function returns a random variate from the flat (uniform) distribution from $a to $b.
This function computes the probability density p(x) at $x for a uniform distribution from $a to $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for a uniform distribution from $a to $b.
This function returns a random variate from the lognormal distribution.
This function computes the probability density p(x) at $x for a lognormal distribution with parameters $zeta and $sigma.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the lognormal distribution with parameters $zeta and $sigma.
This function returns a random variate from the chi-squared distribution with $nu degrees of freedom.
This function computes the probability density p(x) at $x for a chi-squared distribution with $nu degrees of freedom.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the chi-squared distribution with $nu degrees of freedom.
This function returns a random variate from the F-distribution with degrees of freedom $nu1 and $nu2.
This function computes the probability density p(x) at $x for an F-distribution with $nu1 and $nu2 degrees of freedom.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the F-distribution with $nu1 and $nu2 degrees of freedom.
This function returns a random variate from the t-distribution.
This function computes the probability density p(x) at $x for a t-distribution with $nu degrees of freedom.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the t-distribution with $nu degrees of freedom.
This function returns a random variate from the beta distribution.
This function computes the probability density p(x) at $x for a beta distribution with parameters $a and $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the beta distribution with parameters $a and $b.
This function returns a random variate from the logistic distribution.
This function computes the probability density p(x) at $x for a logistic distribution with scale parameter $a.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the logistic distribution with scale parameter $a.
This function returns a random variate from the Pareto distribution of order $a and scale $b.
This function computes the probability density p(x) at $x for a Pareto distribution with exponent $a and scale $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Pareto distribution with exponent $a and scale $b.
This function returns a random direction vector v = (x, y) in two dimensions. The return value is a List of two Num(s): the x and y components of the 2D vector.
This function returns a random direction vector v = (x, y, z) in three dimensions. The return value is a List of three Num(s): the x, y, and z components of the 3D vector.
This function returns a random direction vector v = (x 1 , x 2 , . . . , x n ) in $n dimensions. The return value is a List of $n Num(s): the components of the n-D vector.
This function returns a random variate from the Weibull distribution.
This function computes the probability density p(x) at $x for a Weibull distribution with scale $a and exponent $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Weibull distribution with scale $a and exponent $b.
This function returns a random variate from the Type-1 Gumbel distribution.
This function computes the probability density p(x) at $x for a Type-1 Gumbel distribution with parameters $a and $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Type-1 Gumbel distribution with parameters $a and $b.
This function returns a random variate from the Type-2 Gumbel distribution.
This function computes the probability density p(x) at $x for a Type-2 Gumbel distribution with parameters $a and $b.
These functions compute the cumulative distribution functions P(x), Q(x) and their inverses for the Type-2 Gumbel distribution with parameters $a and $b.
This function returns an array of K random variates as a List of Num(s) from a Dirichlet distribution of order K-1.
This function computes the probability density p(θ₁, …, θₖ) at theta[K] for a Dirichlet distribution with parameters alpha[K].
This function computes the logarithm of the probability density p(θ₁, …, θₖ) at theta[K] for a Dirichlet distribution with parameters alpha[K].
This function returns a random integer from the Poisson distribution with mean $mu.
This function computes the probability p(k) of obtaining $k from a Poisson distribution with mean $mu.
These functions compute the cumulative distribution functions P(k), Q(k) for the Poisson distribution with parameter $mu.
This function returns either 0 or 1, the result of a Bernoulli trial with probability $p.
This function computes the probability p(k) of obtaining $k from a Bernoulli distribution with probability parameter $p.
This function returns a random integer from the binomial distribution, the number of successes in $n independent trials with probability $p.
This function computes the probability p(k) of obtaining $k from a binomial distribution with parameters $p and $n.
These functions compute the cumulative distribution functions P (k), Q(k) for the binomial distribution with parameters $p and $n.
This function returns a random sample from the multinomial distribution formed by $N trials from an underlying distribution p[K] as a List of UInt(s).
This function computes the probability P(n₁, n₂, …, nₖ) of sampling n[K] from a multinomial distribution with parameters p[K].
This function computes the logarithm of the probability P(n₁, n₂, …, nₖ) for the multinomial distribution with parameters p[K].
This function returns a random integer from the negative binomial distribution.
This function computes the probability p(k) of obtaining $k from a negative binomial distribution with parameters $p and $n.
These functions compute the cumulative distribution functions P(k), Q(k) for the negative binomial distribution with parameters $p and $n.
This function returns a random integer from the Pascal distribution.
This function computes the probability p(k) of obtaining $k from a Pascal distribution with parameters $p and $n.
These functions compute the cumulative distribution functions P(k), Q(k) for the Pascal distribution with parameters $p and $n.
This function returns a random integer from the geometric distribution, the number of independent trials with probability $p until the first success.
This function computes the probability p(k) of obtaining $k from a geometric distribution with probability parameter $p.
These functions compute the cumulative distribution functions P(k), Q(k) for the geometric distribution with parameter $p.
This function returns a random integer from the hypergeometric distribution.
This function computes the probability p(k) of obtaining $k from a hypergeometric distribution with parameters $n1, $n2, $t.
These functions compute the cumulative distribution functions P(k), Q(k) for the hypergeometric distribution with parameters $n1, $n2 and $t.
This function returns a random integer from the logarithmic distribution.
This function computes the probability p(k) of obtaining $k from a logarithmic distribution with probability parameter $p.
This function returns a random symmetric p-by-p matrix from the Wishart distribution as a Math::Libgsl::Matrix object.
These functions return p(X) or log p(X) for the p-by-p matrix $X, whose Cholesky factor is specified in $L-X. The degrees of freedom is given by $n, the Cholesky factor of the scale matrix V is specified in $L.
This function randomly shuffles the order of the elements of the array @base and returns them as a List.
This function returns the list of $k objects taken randomly from the elements of the array @src.
This function is like choose() but samples $k items from the original array of n items @src with replacement, so the same object can appear more than once in the output.
This probability distribution needs a lookup table for the discrete random number generator, so it's implemented as a class, which hides the implementation details.
use Math::Libgsl::RandomDistribution; use Math::Libgsl::Random; my Int $size = 3; my @probability = .59, .4, .01; my Math::Libgsl::Random $r .= new; my Math::Libgsl::RandomDistribution::Discrete $d .= new: :$size, :@probability; say "Using probability values: { $d.probability }"; say $d.discrete($r) for ^10; say $d.discrete-pdf(2);
Creates the lookup table for the discrete random number generator. The array @probability contains the probabilities of the discrete events.
This method returns one discrete random number.
This method returns the probability P[k] of observing the variable $k.
For more details on libgsl see https://www.gnu.org/software/gsl/. The excellent C Library manual is available here https://www.gnu.org/software/gsl/doc/html/index.html, or here https://www.gnu.org/software/gsl/doc/latex/gsl-ref.pdf in PDF format.
This module requires the libgsl library to be installed. Please follow the instructions below based on your platform:
sudo apt install libgsl23 libgsl-dev libgslcblas0
That command will install libgslcblas0 as well, since it's used by the GSL.
libgsl23 and libgslcblas0 have a missing symbol on Ubuntu 18.04. I solved the issue installing the Debian Buster version of those three libraries:
http://http.us.debian.org/debian/pool/main/g/gsl/libgslcblas0_2.5+dfsg-6_amd64.deb
http://http.us.debian.org/debian/pool/main/g/gsl/libgsl23_2.5+dfsg-6_amd64.deb
http://http.us.debian.org/debian/pool/main/g/gsl/libgsl-dev_2.5+dfsg-6_amd64.deb
To install it using zef (a module management tool):
$ zef install Math::Libgsl::RandomDistribution
Fernando Santagata [email protected]
Copyright 2020 Fernando Santagata
This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.