diff --git a/previews/PR1908/censored/index.html b/previews/PR1908/censored/index.html index 53460d4fb..326627f60 100644 --- a/previews/PR1908/censored/index.html +++ b/previews/PR1908/censored/index.html @@ -7,4 +7,4 @@ \end{cases}, \quad x \in [l, u]\]

where $f_{d_0}(x)$ is the probability density (mass) function of $d_0$.

If $Z \sim d_0$, and X = clamp(Z, l, u), then $X \sim d$. Note that this implies that even if $d_0$ is continuous, its censored form assigns positive probability to the bounds $l$ and $u$. Therefore, a censored continuous distribution has atoms and is a mixture of discrete and continuous components.

The function falls back to constructing a Distributions.Censored wrapper.

Usage

censored(d0; lower=l)           # d0 left-censored to the interval [l, Inf)
 censored(d0; upper=u)           # d0 right-censored to the interval (-Inf, u]
 censored(d0; lower=l, upper=u)  # d0 interval-censored to the interval [l, u]
-censored(d0, l, u)              # d0 interval-censored to the interval [l, u]

Implementation

To implement a specialized censored form for distributions of type D, instead of overloading a method with one of the above signatures, one or more of the following methods should be implemented:

source

In the general case, this will create a Distributions.Censored{typeof(d0)} structure, defined as follows:

Distributions.CensoredType
Censored

Generic wrapper for a censored distribution.

source

In general, censored should be called instead of the constructor of Censored, which is not exported.

Many functions, including those for the evaluation of pdf and sampling, are defined for all censored univariate distributions:

Some functions to compute statistics are available for the censored distribution if they are also available for its truncation:

For example, these functions are available for the following uncensored distributions:

mode is not implemented for censored distributions.

+censored(d0, l, u) # d0 interval-censored to the interval [l, u]

Implementation

To implement a specialized censored form for distributions of type D, instead of overloading a method with one of the above signatures, one or more of the following methods should be implemented:

source

In the general case, this will create a Distributions.Censored{typeof(d0)} structure, defined as follows:

Distributions.CensoredType
Censored

Generic wrapper for a censored distribution.

source

In general, censored should be called instead of the constructor of Censored, which is not exported.

Many functions, including those for the evaluation of pdf and sampling, are defined for all censored univariate distributions:

Some functions to compute statistics are available for the censored distribution if they are also available for its truncation:

For example, these functions are available for the following uncensored distributions:

mode is not implemented for censored distributions.

diff --git a/previews/PR1908/cholesky/index.html b/previews/PR1908/cholesky/index.html index b7114ee73..f3329299d 100644 --- a/previews/PR1908/cholesky/index.html +++ b/previews/PR1908/cholesky/index.html @@ -1,2 +1,2 @@ -Cholesky-variate Distributions · Distributions.jl

Cholesky-variate Distributions

Cholesky-variate distributions are distributions whose variate forms are CholeskyVariate. This means each draw is a factorization of a positive-definite matrix of type LinearAlgebra.Cholesky (the object produced by the function LinearAlgebra.cholesky applied to a dense positive-definite matrix.)

Distributions

Distributions.LKJCholeskyType
LKJCholesky(d::Int, η::Real, uplo='L')

The LKJCholesky distribution of size $d$ with shape parameter $\eta$ is a distribution over LinearAlgebra.Cholesky factorisations of $d\times d$ real correlation matrices (positive-definite matrices with ones on the diagonal).

Variates or samples of the distribution are LinearAlgebra.Cholesky objects, as might be returned by F = LinearAlgebra.cholesky(R), so that Matrix(F) ≈ R is a variate or sample of LKJ.

Sampling LKJCholesky is faster than sampling LKJ, and often having the correlation matrix in factorized form makes subsequent computations cheaper as well.

Note

LinearAlgebra.Cholesky stores either the upper or lower Cholesky factor, related by F.U == F.L'. Both can be accessed with F.U and F.L, but if the factor not stored is requested, then a copy is made. The uplo parameter specifies whether the upper ('U') or lower ('L') Cholesky factor is stored when randomly generating samples. Set uplo to 'U' if the upper factor is desired to avoid allocating a copy when calling F.U.

See LKJ for more details.

External links

  • Lewandowski D, Kurowicka D, Joe H. Generating random correlation matrices based on vines and extended onion method, Journal of Multivariate Analysis (2009), 100(9): 1989-2001 doi: 10.1016/j.jmva.2009.04.008
source

Index

+Cholesky-variate Distributions · Distributions.jl

Cholesky-variate Distributions

Cholesky-variate distributions are distributions whose variate forms are CholeskyVariate. This means each draw is a factorization of a positive-definite matrix of type LinearAlgebra.Cholesky (the object produced by the function LinearAlgebra.cholesky applied to a dense positive-definite matrix.)

Distributions

Distributions.LKJCholeskyType
LKJCholesky(d::Int, η::Real, uplo='L')

The LKJCholesky distribution of size $d$ with shape parameter $\eta$ is a distribution over LinearAlgebra.Cholesky factorisations of $d\times d$ real correlation matrices (positive-definite matrices with ones on the diagonal).

Variates or samples of the distribution are LinearAlgebra.Cholesky objects, as might be returned by F = LinearAlgebra.cholesky(R), so that Matrix(F) ≈ R is a variate or sample of LKJ.

Sampling LKJCholesky is faster than sampling LKJ, and often having the correlation matrix in factorized form makes subsequent computations cheaper as well.

Note

LinearAlgebra.Cholesky stores either the upper or lower Cholesky factor, related by F.U == F.L'. Both can be accessed with F.U and F.L, but if the factor not stored is requested, then a copy is made. The uplo parameter specifies whether the upper ('U') or lower ('L') Cholesky factor is stored when randomly generating samples. Set uplo to 'U' if the upper factor is desired to avoid allocating a copy when calling F.U.

See LKJ for more details.

External links

  • Lewandowski D, Kurowicka D, Joe H. Generating random correlation matrices based on vines and extended onion method, Journal of Multivariate Analysis (2009), 100(9): 1989-2001 doi: 10.1016/j.jmva.2009.04.008
source

Index

diff --git a/previews/PR1908/convolution/index.html b/previews/PR1908/convolution/index.html index f6b26a086..402c8b616 100644 --- a/previews/PR1908/convolution/index.html +++ b/previews/PR1908/convolution/index.html @@ -1,2 +1,2 @@ -Convolutions · Distributions.jl

Convolutions

A convolution of two probability distributions is the probability distribution of the sum of two independent random variables that are distributed according to these distributions.

The convolution of two distributions can be constructed with convolve.

Distributions.convolveFunction
convolve(d1::Distribution, d2::Distribution)

Convolve two distributions and return the distribution corresponding to the sum of independent random variables drawn from the underlying distributions.

Currently, the function is only defined in cases where the convolution has a closed form. More precisely, the function is defined if the distributions of d1 and d2 are the same and one of

External links: List of convolutions of probability distributions on Wikipedia

source
+Convolutions · Distributions.jl

Convolutions

A convolution of two probability distributions is the probability distribution of the sum of two independent random variables that are distributed according to these distributions.

The convolution of two distributions can be constructed with convolve.

Distributions.convolveFunction
convolve(d1::Distribution, d2::Distribution)

Convolve two distributions and return the distribution corresponding to the sum of independent random variables drawn from the underlying distributions.

Currently, the function is only defined in cases where the convolution has a closed form. More precisely, the function is defined if the distributions of d1 and d2 are the same and one of

External links: List of convolutions of probability distributions on Wikipedia

source
diff --git a/previews/PR1908/density_interface/index.html b/previews/PR1908/density_interface/index.html index 234d588ec..9e567ce86 100644 --- a/previews/PR1908/density_interface/index.html +++ b/previews/PR1908/density_interface/index.html @@ -1,2 +1,2 @@ -Support for DensityInterface · Distributions.jl

Support for DensityInterface

Distributions supports DensityInterface for distributions.

A probability distribution has a probability density, so DensityInterface.DensityKind(::Distribution) === HasDensity().

For single variate values x, DensityInterface.logdensityof(d::Distribution, x) is equivalent to logpdf(d, x) and DensityInterface.densityof(d::Distribution, x) is equivalent to pdf(d, x).

+Support for DensityInterface · Distributions.jl

Support for DensityInterface

Distributions supports DensityInterface for distributions.

A probability distribution has a probability density, so DensityInterface.DensityKind(::Distribution) === HasDensity().

For single variate values x, DensityInterface.logdensityof(d::Distribution, x) is equivalent to logpdf(d, x) and DensityInterface.densityof(d::Distribution, x) is equivalent to pdf(d, x).

diff --git a/previews/PR1908/extends/index.html b/previews/PR1908/extends/index.html index 546969849..3f6871c00 100644 --- a/previews/PR1908/extends/index.html +++ b/previews/PR1908/extends/index.html @@ -35,4 +35,4 @@ function _rand!(rng::AbstractRNG, s::Spl, x::DenseMatrix{T}) where T<:Real # ... generate a single matrix sample to x end

Note that you can assume x has correct dimensions in _rand! and don't have to perform dimension checking, the generic rand and rand! will do dimension checking and array allocation for you.

Create a Distribution

Most distributions should implement a sampler method to improve batch sampling efficiency.

Distributions.samplerMethod
sampler(d::Distribution) -> Sampleable
-sampler(s::Sampleable) -> s

Samplers can often rely on pre-computed quantities (that are not parameters themselves) to improve efficiency. If such a sampler exists, it can be provided with this sampler method, which would be used for batch sampling. The general fallback is sampler(d::Distribution) = d.

source

Univariate Distribution

A univariate distribution type should be defined as a subtype of DiscreteUnivarateDistribution or ContinuousUnivariateDistribution.

The following methods need to be implemented for each univariate distribution type:

It is also recommended that one also implements the following statistics functions:

You may refer to the source file src/univariates.jl to see details about how generic fallback functions for univariates are implemented.

Create a Multivariate Distribution

A multivariate distribution type should be defined as a subtype of DiscreteMultivarateDistribution or ContinuousMultivariateDistribution.

The following methods need to be implemented for each multivariate distribution type:

Note that if there exist faster methods for batch evaluation, one should override _logpdf! and _pdf!.

Furthermore, the generic loglikelihood function repeatedly calls _logpdf. If there is a better way to compute the log-likelihood, one should override loglikelihood.

It is also recommended that one also implements the following statistics functions:

Create a Matrix-Variate Distribution

A matrix-variate distribution type should be defined as a subtype of DiscreteMatrixDistribution or ContinuousMatrixDistribution.

The following methods need to be implemented for each matrix-variate distribution type:

+sampler(s::Sampleable) -> s

Samplers can often rely on pre-computed quantities (that are not parameters themselves) to improve efficiency. If such a sampler exists, it can be provided with this sampler method, which would be used for batch sampling. The general fallback is sampler(d::Distribution) = d.

source

Univariate Distribution

A univariate distribution type should be defined as a subtype of DiscreteUnivarateDistribution or ContinuousUnivariateDistribution.

The following methods need to be implemented for each univariate distribution type:

It is also recommended that one also implements the following statistics functions:

You may refer to the source file src/univariates.jl to see details about how generic fallback functions for univariates are implemented.

Create a Multivariate Distribution

A multivariate distribution type should be defined as a subtype of DiscreteMultivarateDistribution or ContinuousMultivariateDistribution.

The following methods need to be implemented for each multivariate distribution type:

Note that if there exist faster methods for batch evaluation, one should override _logpdf! and _pdf!.

Furthermore, the generic loglikelihood function repeatedly calls _logpdf. If there is a better way to compute the log-likelihood, one should override loglikelihood.

It is also recommended that one also implements the following statistics functions:

Create a Matrix-Variate Distribution

A matrix-variate distribution type should be defined as a subtype of DiscreteMatrixDistribution or ContinuousMatrixDistribution.

The following methods need to be implemented for each matrix-variate distribution type:

diff --git a/previews/PR1908/fit/index.html b/previews/PR1908/fit/index.html index 9a501589e..e58a6d0b3 100644 --- a/previews/PR1908/fit/index.html +++ b/previews/PR1908/fit/index.html @@ -1,6 +1,6 @@ Distribution Fitting · Distributions.jl

Distribution Fitting

This package provides methods to fit a distribution to a given set of samples. Generally, one may write

d = fit(D, x)

This statement fits a distribution of type D to a given dataset x, where x should be an array comprised of all samples. The fit function will choose a reasonable way to fit the distribution, which, in most cases, is maximum likelihood estimation.

Note

One can use as the first argument simply the distribution name, like Binomial, or a concrete distribution with a type parameter, like Normal{Float64} or Exponential{Float32}. However, in the latter case the type parameter of the distribution will be ignored:

julia> fit(Cauchy{Float32}, collect(-4:4))
-Cauchy{Float64}(μ=0.0, σ=2.0)

Maximum Likelihood Estimation

The function fit_mle is for maximum likelihood estimation.

Synopsis

Missing docstring.

Missing docstring for fit(D, x). Check Documenter's build log for details.

Missing docstring.

Missing docstring for fit(D, x, w). Check Documenter's build log for details.

Distributions.fit_mleMethod
fit_mle(D, x)

Fit a distribution of type D to a given data set x.

  • For univariate distribution, x can be an array of arbitrary size.
  • For multivariate distribution, x should be a matrix, where each column is a sample.
source
Distributions.fit_mleMethod
fit_mle(D, x, w)

Fit a distribution of type D to a weighted data set x, with weights given by w.

Here, w should be an array with length n, where n is the number of samples contained in x.

source

Applicable distributions

The fit_mle method has been implemented for the following distributions:

Univariate:

Multivariate:

For most of these distributions, the usage is as described above. For a few special distributions that require additional information for estimation, we have to use a modified interface:

fit_mle(Binomial, n, x)        # n is the number of trials in each experiment
+Cauchy{Float64}(μ=0.0, σ=2.0)

Maximum Likelihood Estimation

The function fit_mle is for maximum likelihood estimation.

Synopsis

Missing docstring.

Missing docstring for fit(D, x). Check Documenter's build log for details.

Missing docstring.

Missing docstring for fit(D, x, w). Check Documenter's build log for details.

Distributions.fit_mleMethod
fit_mle(D, x)

Fit a distribution of type D to a given data set x.

  • For univariate distribution, x can be an array of arbitrary size.
  • For multivariate distribution, x should be a matrix, where each column is a sample.
source
Distributions.fit_mleMethod
fit_mle(D, x, w)

Fit a distribution of type D to a weighted data set x, with weights given by w.

Here, w should be an array with length n, where n is the number of samples contained in x.

source

Applicable distributions

The fit_mle method has been implemented for the following distributions:

Univariate:

Multivariate:

For most of these distributions, the usage is as described above. For a few special distributions that require additional information for estimation, we have to use a modified interface:

fit_mle(Binomial, n, x)        # n is the number of trials in each experiment
 fit_mle(Binomial, n, x, w)
 
 fit_mle(Categorical, k, x)     # k is the space size (i.e. the number of distinct values)
@@ -10,4 +10,4 @@
 fit_mle(Categorical, x, w)

Sufficient Statistics

For many distributions, the estimation can be based on (sum of) sufficient statistics computed from a dataset. To simplify implementation, for such distributions, we implement suffstats method instead of fit_mle directly:

ss = suffstats(D, x)        # ss captures the sufficient statistics of x
 ss = suffstats(D, x, w)     # ss captures the sufficient statistics of a weighted dataset
 
-d = fit_mle(D, ss)          # maximum likelihood estimation based on sufficient stats

When fit_mle on D is invoked, a fallback fit_mle method will first call suffstats to compute the sufficient statistics, and then a fit_mle method on sufficient statistics to get the result. For some distributions, this way is not the most efficient, and we specialize the fit_mle method to implement more efficient estimation algorithms.

Maximum-a-Posteriori Estimation

Maximum-a-Posteriori (MAP) estimation is also supported by this package, which is implemented as part of the conjugate exponential family framework (see :ref:Conjugate Prior and Posterior <ref-conj>).

+d = fit_mle(D, ss) # maximum likelihood estimation based on sufficient stats

When fit_mle on D is invoked, a fallback fit_mle method will first call suffstats to compute the sufficient statistics, and then a fit_mle method on sufficient statistics to get the result. For some distributions, this way is not the most efficient, and we specialize the fit_mle method to implement more efficient estimation algorithms.

Maximum-a-Posteriori Estimation

Maximum-a-Posteriori (MAP) estimation is also supported by this package, which is implemented as part of the conjugate exponential family framework (see :ref:Conjugate Prior and Posterior <ref-conj>).

diff --git a/previews/PR1908/index.html b/previews/PR1908/index.html index 170cc8a71..8f1555515 100644 --- a/previews/PR1908/index.html +++ b/previews/PR1908/index.html @@ -1,2 +1,2 @@ -Distributions Package · Distributions.jl

Distributions Package

The Distributions package provides a large collection of probabilistic distributions and related functions. Particularly, Distributions implements:

  • Sampling from distributions
  • Moments (e.g mean, variance, skewness, and kurtosis), entropy, and other properties
  • Probability density/mass functions (pdf) and their logarithm (logpdf)
  • Moment-generating functions and characteristic functions
  • Maximum likelihood estimation
  • Distribution composition and derived distributions (Cartesian product of distributions, truncated distributions, censored distributions)
+Distributions Package · Distributions.jl

Distributions Package

The Distributions package provides a large collection of probabilistic distributions and related functions. Particularly, Distributions implements:

  • Sampling from distributions
  • Moments (e.g mean, variance, skewness, and kurtosis), entropy, and other properties
  • Probability density/mass functions (pdf) and their logarithm (logpdf)
  • Moment-generating functions and characteristic functions
  • Maximum likelihood estimation
  • Distribution composition and derived distributions (Cartesian product of distributions, truncated distributions, censored distributions)
diff --git a/previews/PR1908/matrix/index.html b/previews/PR1908/matrix/index.html index 2c164b71b..ab8b240af 100644 --- a/previews/PR1908/matrix/index.html +++ b/previews/PR1908/matrix/index.html @@ -2,30 +2,30 @@ Matrix-variate Distributions · Distributions.jl

Matrix-variate Distributions

Matrix-variate distributions are the distributions whose variate forms are Matrixvariate (i.e each sample is a matrix). Abstract types for matrix-variate distributions:

const MatrixDistribution{S<:ValueSupport} = Distribution{Matrixvariate,S}
 
 const DiscreteMatrixDistribution   = Distribution{Matrixvariate, Discrete}
-const ContinuousMatrixDistribution = Distribution{Matrixvariate, Continuous}

More advanced functionalities related to random matrices can be found in the RandomMatrices.jl package.

Common Interface

All distributions implement the same set of methods:

Base.sizeMethod
size(d::MatrixDistribution)

Return the size of each sample from distribution d.

source
Base.lengthMethod
length(d::MatrixDistribution)

The length (i.e number of elements) of each sample from the distribution d.

source
Statistics.varMethod
var(d::MatrixDistribution)

Compute the matrix of element-wise variances for distribution d.

source
Statistics.covMethod
cov(d::MatrixDistribution)

Compute the covariance matrix for vec(X), where X is a random matrix with distribution d.

source
Distributions.pdfMethod
pdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of pdf one should implement _pdf(d, x) which does not have to check the size of x. However, since the default definition of pdf(d, x) falls back to logpdf(d, x) usually it is sufficient to implement logpdf.

See also: logpdf.

source
Distributions.logpdfMethod
logpdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the logarithm of the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of logpdf one should implement _logpdf(d, x) which does not have to check the size of x.

See also: pdf.

source
Missing docstring.

Missing docstring for Distributions._rand!(::AbstractRNG, ::MatrixDistribution, A::AbstractMatrix). Check Documenter's build log for details.

Distributions

Distributions.MatrixNormalType
MatrixNormal(M, U, V)
M::AbstractMatrix  n x p mean
+const ContinuousMatrixDistribution = Distribution{Matrixvariate, Continuous}

More advanced functionalities related to random matrices can be found in the RandomMatrices.jl package.

Common Interface

All distributions implement the same set of methods:

Base.sizeMethod
size(d::MatrixDistribution)

Return the size of each sample from distribution d.

source
Base.lengthMethod
length(d::MatrixDistribution)

The length (i.e number of elements) of each sample from the distribution d.

source
Statistics.varMethod
var(d::MatrixDistribution)

Compute the matrix of element-wise variances for distribution d.

source
Statistics.covMethod
cov(d::MatrixDistribution)

Compute the covariance matrix for vec(X), where X is a random matrix with distribution d.

source
Distributions.pdfMethod
pdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of pdf one should implement _pdf(d, x) which does not have to check the size of x. However, since the default definition of pdf(d, x) falls back to logpdf(d, x) usually it is sufficient to implement logpdf.

See also: logpdf.

source
Distributions.logpdfMethod
logpdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}

Evaluate the logarithm of the probability density function of d at x.

This function checks if the size of x is compatible with distribution d. This check can be disabled by using @inbounds.

Implementation

Instead of logpdf one should implement _logpdf(d, x) which does not have to check the size of x.

See also: pdf.

source
Missing docstring.

Missing docstring for Distributions._rand!(::AbstractRNG, ::MatrixDistribution, A::AbstractMatrix). Check Documenter's build log for details.

Distributions

Distributions.MatrixNormalType
MatrixNormal(M, U, V)
M::AbstractMatrix  n x p mean
 U::AbstractPDMat   n x n row covariance
-V::AbstractPDMat   p x p column covariance

The matrix normal distribution generalizes the multivariate normal distribution to $n\times p$ real matrices $\mathbf{X}$. If $\mathbf{X}\sim \textrm{MN}_{n,p}(\mathbf{M}, \mathbf{U}, \mathbf{V})$, then its probability density function is

\[f(\mathbf{X};\mathbf{M}, \mathbf{U}, \mathbf{V}) = \frac{\exp\left( -\frac{1}{2} \, \mathrm{tr}\left[ \mathbf{V}^{-1} (\mathbf{X} - \mathbf{M})^{\rm{T}} \mathbf{U}^{-1} (\mathbf{X} - \mathbf{M}) \right] \right)}{(2\pi)^{np/2} |\mathbf{V}|^{n/2} |\mathbf{U}|^{p/2}}.\]

$\mathbf{X}\sim \textrm{MN}_{n,p}(\mathbf{M},\mathbf{U},\mathbf{V})$ if and only if $\text{vec}(\mathbf{X})\sim \textrm{N}(\text{vec}(\mathbf{M}),\mathbf{V}\otimes\mathbf{U})$.

source
Distributions.WishartType
Wishart(ν, S)
ν::Real           degrees of freedom (whole number or a real number greater than p - 1)
+V::AbstractPDMat   p x p column covariance

The matrix normal distribution generalizes the multivariate normal distribution to $n\times p$ real matrices $\mathbf{X}$. If $\mathbf{X}\sim \textrm{MN}_{n,p}(\mathbf{M}, \mathbf{U}, \mathbf{V})$, then its probability density function is

\[f(\mathbf{X};\mathbf{M}, \mathbf{U}, \mathbf{V}) = \frac{\exp\left( -\frac{1}{2} \, \mathrm{tr}\left[ \mathbf{V}^{-1} (\mathbf{X} - \mathbf{M})^{\rm{T}} \mathbf{U}^{-1} (\mathbf{X} - \mathbf{M}) \right] \right)}{(2\pi)^{np/2} |\mathbf{V}|^{n/2} |\mathbf{U}|^{p/2}}.\]

$\mathbf{X}\sim \textrm{MN}_{n,p}(\mathbf{M},\mathbf{U},\mathbf{V})$ if and only if $\text{vec}(\mathbf{X})\sim \textrm{N}(\text{vec}(\mathbf{M}),\mathbf{V}\otimes\mathbf{U})$.

source
Distributions.WishartType
Wishart(ν, S)
ν::Real           degrees of freedom (whole number or a real number greater than p - 1)
 S::AbstractPDMat  p x p scale matrix

The Wishart distribution generalizes the gamma distribution to $p\times p$ real, positive semidefinite matrices $\mathbf{H}$.

If $\nu>p-1$, then $\mathbf{H}\sim \textrm{W}_p(\nu, \mathbf{S})$ has rank $p$ and its probability density function is

\[f(\mathbf{H};\nu,\mathbf{S}) = \frac{1}{2^{\nu p/2} \left|\mathbf{S}\right|^{\nu/2} \Gamma_p\left(\frac {\nu}{2}\right ) }{\left|\mathbf{H}\right|}^{(\nu-p-1)/2} e^{-(1/2)\operatorname{tr}(\mathbf{S}^{-1}\mathbf{H})}.\]

If $\nu\leq p-1$, then $\mathbf{H}$ is rank $\nu$ and it has a density with respect to a suitably chosen volume element on the space of positive semidefinite matrices. See here.

For integer $\nu$, a random matrix given by

\[\mathbf{H} = \mathbf{X}\mathbf{X}^{\rm{T}}, -\quad\mathbf{X} \sim \textrm{MN}_{p,\nu}(\mathbf{0}, \mathbf{S}, \mathbf{I}_{\nu})\]

has $\mathbf{H}\sim \textrm{W}_p(\nu, \mathbf{S})$. For non-integer $\nu$, Wishart matrices can be generated via the Bartlett decomposition.

source
Distributions.InverseWishartType
InverseWishart(ν, Ψ)
ν::Real           degrees of freedom (greater than p - 1)
+\quad\mathbf{X} \sim \textrm{MN}_{p,\nu}(\mathbf{0}, \mathbf{S}, \mathbf{I}_{\nu})\]

has $\mathbf{H}\sim \textrm{W}_p(\nu, \mathbf{S})$. For non-integer $\nu$, Wishart matrices can be generated via the Bartlett decomposition.

source
Distributions.InverseWishartType
InverseWishart(ν, Ψ)
ν::Real           degrees of freedom (greater than p - 1)
 Ψ::AbstractPDMat  p x p scale matrix

The inverse Wishart distribution generalizes the inverse gamma distribution to $p\times p$ real, positive definite matrices $\boldsymbol{\Sigma}$. If $\boldsymbol{\Sigma}\sim \textrm{IW}_p(\nu,\boldsymbol{\Psi})$, then its probability density function is

\[f(\boldsymbol{\Sigma}; \nu,\boldsymbol{\Psi}) = -\frac{\left|\boldsymbol{\Psi}\right|^{\nu/2}}{2^{\nu p/2}\Gamma_p(\frac{\nu}{2})} \left|\boldsymbol{\Sigma}\right|^{-(\nu+p+1)/2} e^{-\frac{1}{2}\operatorname{tr}(\boldsymbol{\Psi}\boldsymbol{\Sigma}^{-1})}.\]

$\mathbf{H}\sim \textrm{W}_p(\nu, \mathbf{S})$ if and only if $\mathbf{H}^{-1}\sim \textrm{IW}_p(\nu, \mathbf{S}^{-1})$.

source
Distributions.MatrixTDistType
MatrixTDist(ν, M, Σ, Ω)
ν::Real            positive degrees of freedom
+\frac{\left|\boldsymbol{\Psi}\right|^{\nu/2}}{2^{\nu p/2}\Gamma_p(\frac{\nu}{2})} \left|\boldsymbol{\Sigma}\right|^{-(\nu+p+1)/2} e^{-\frac{1}{2}\operatorname{tr}(\boldsymbol{\Psi}\boldsymbol{\Sigma}^{-1})}.\]

$\mathbf{H}\sim \textrm{W}_p(\nu, \mathbf{S})$ if and only if $\mathbf{H}^{-1}\sim \textrm{IW}_p(\nu, \mathbf{S}^{-1})$.

source
Distributions.MatrixTDistType
MatrixTDist(ν, M, Σ, Ω)
ν::Real            positive degrees of freedom
 M::AbstractMatrix  n x p location
 Σ::AbstractPDMat   n x n scale
 Ω::AbstractPDMat   p x p scale

The matrix t-distribution generalizes the multivariate t-distribution to $n\times p$ real matrices $\mathbf{X}$. If $\mathbf{X}\sim \textrm{MT}_{n,p}(\nu,\mathbf{M},\boldsymbol{\Sigma}, \boldsymbol{\Omega})$, then its probability density function is

\[f(\mathbf{X} ; \nu,\mathbf{M},\boldsymbol{\Sigma}, \boldsymbol{\Omega}) = c_0 \left|\mathbf{I}_n + \boldsymbol{\Sigma}^{-1}(\mathbf{X} - \mathbf{M})\boldsymbol{\Omega}^{-1}(\mathbf{X}-\mathbf{M})^{\rm{T}}\right|^{-\frac{\nu+n+p-1}{2}},\]

where

\[c_0=\frac{\Gamma_p\left(\frac{\nu+n+p-1}{2}\right)}{(\pi)^\frac{np}{2} \Gamma_p\left(\frac{\nu+p-1}{2}\right)} |\boldsymbol{\Omega}|^{-\frac{n}{2}} |\boldsymbol{\Sigma}|^{-\frac{p}{2}}.\]

If the joint distribution $p(\mathbf{S},\mathbf{X})=p(\mathbf{S})p(\mathbf{X}|\mathbf{S})$ is given by

\[\begin{aligned} \mathbf{S}&\sim \textrm{IW}_n(\nu + n - 1, \boldsymbol{\Sigma})\\ \mathbf{X}|\mathbf{S}&\sim \textrm{MN}_{n,p}(\mathbf{M}, \mathbf{S}, \boldsymbol{\Omega}), -\end{aligned}\]

then the marginal distribution of $\mathbf{X}$ is $\textrm{MT}_{n,p}(\nu,\mathbf{M},\boldsymbol{\Sigma},\boldsymbol{\Omega})$.

source
Distributions.MatrixBetaType
MatrixBeta(p, n1, n2)
p::Int    dimension
+\end{aligned}\]

then the marginal distribution of $\mathbf{X}$ is $\textrm{MT}_{n,p}(\nu,\mathbf{M},\boldsymbol{\Sigma},\boldsymbol{\Omega})$.

source
Distributions.MatrixBetaType
MatrixBeta(p, n1, n2)
p::Int    dimension
 n1::Real  degrees of freedom (greater than p - 1)
 n2::Real  degrees of freedom (greater than p - 1)

The matrix beta distribution generalizes the beta distribution to $p\times p$ real matrices $\mathbf{U}$ for which $\mathbf{U}$ and $\mathbf{I}_p-\mathbf{U}$ are both positive definite. If $\mathbf{U}\sim \textrm{MB}_p(n_1/2, n_2/2)$, then its probability density function is

\[f(\mathbf{U}; n_1,n_2) = \frac{\Gamma_p(\frac{n_1+n_2}{2})}{\Gamma_p(\frac{n_1}{2})\Gamma_p(\frac{n_2}{2})} -|\mathbf{U}|^{(n_1-p-1)/2}\left|\mathbf{I}_p-\mathbf{U}\right|^{(n_2-p-1)/2}.\]

If $\mathbf{S}_1\sim \textrm{W}_p(n_1,\mathbf{I}_p)$ and $\mathbf{S}_2\sim \textrm{W}_p(n_2,\mathbf{I}_p)$ are independent, and we use $\mathcal{L}(\cdot)$ to denote the lower Cholesky factor, then

\[\mathbf{U}=\mathcal{L}(\mathbf{S}_1+\mathbf{S}_2)^{-1}\mathbf{S}_1\mathcal{L}(\mathbf{S}_1+\mathbf{S}_2)^{-\rm{T}}\]

has $\mathbf{U}\sim \textrm{MB}_p(n_1/2, n_2/2)$.

source
Distributions.MatrixFDistType
MatrixFDist(n1, n2, B)
n1::Real          degrees of freedom (greater than p - 1)
+|\mathbf{U}|^{(n_1-p-1)/2}\left|\mathbf{I}_p-\mathbf{U}\right|^{(n_2-p-1)/2}.\]

If $\mathbf{S}_1\sim \textrm{W}_p(n_1,\mathbf{I}_p)$ and $\mathbf{S}_2\sim \textrm{W}_p(n_2,\mathbf{I}_p)$ are independent, and we use $\mathcal{L}(\cdot)$ to denote the lower Cholesky factor, then

\[\mathbf{U}=\mathcal{L}(\mathbf{S}_1+\mathbf{S}_2)^{-1}\mathbf{S}_1\mathcal{L}(\mathbf{S}_1+\mathbf{S}_2)^{-\rm{T}}\]

has $\mathbf{U}\sim \textrm{MB}_p(n_1/2, n_2/2)$.

source
Distributions.MatrixFDistType
MatrixFDist(n1, n2, B)
n1::Real          degrees of freedom (greater than p - 1)
 n2::Real          degrees of freedom (greater than p - 1)
 B::AbstractPDMat  p x p scale

The matrix F-distribution (sometimes called the matrix beta type II distribution) generalizes the F-Distribution to $p\times p$ real, positive definite matrices $\boldsymbol{\Sigma}$. If $\boldsymbol{\Sigma}\sim \textrm{MF}_{p}(n_1/2,n_2/2,\mathbf{B})$, then its probability density function is

\[f(\boldsymbol{\Sigma} ; n_1,n_2,\mathbf{B}) = \frac{\Gamma_p(\frac{n_1+n_2}{2})}{\Gamma_p(\frac{n_1}{2})\Gamma_p(\frac{n_2}{2})} |\mathbf{B}|^{n_2/2}|\boldsymbol{\Sigma}|^{(n_1-p-1)/2}|\mathbf{B}+\boldsymbol{\Sigma}|^{-(n_1+n_2)/2}.\]

If the joint distribution $p(\boldsymbol{\Psi},\boldsymbol{\Sigma})=p(\boldsymbol{\Psi})p(\boldsymbol{\Sigma}|\boldsymbol{\Psi})$ is given by

\[\begin{aligned} \boldsymbol{\Psi}&\sim \textrm{W}_p(n_1, \mathbf{B})\\ \boldsymbol{\Sigma}|\boldsymbol{\Psi}&\sim \textrm{IW}_p(n_2, \boldsymbol{\Psi}), -\end{aligned}\]

then the marginal distribution of $\boldsymbol{\Sigma}$ is $\textrm{MF}_{p}(n_1/2,n_2/2,\mathbf{B})$.

source
Distributions.LKJType
LKJ(d, η)
d::Int   dimension
+\end{aligned}\]

then the marginal distribution of $\boldsymbol{\Sigma}$ is $\textrm{MF}_{p}(n_1/2,n_2/2,\mathbf{B})$.

source
Distributions.LKJType
LKJ(d, η)
d::Int   dimension
 η::Real  positive shape

The LKJ distribution is a distribution over $d\times d$ real correlation matrices (positive-definite matrices with ones on the diagonal). If $\mathbf{R}\sim \textrm{LKJ}_{d}(\eta)$, then its probability density function is

\[f(\mathbf{R};\eta) = \left[\prod_{k=1}^{d-1}\pi^{\frac{k}{2}} \frac{\Gamma\left(\eta+\frac{d-1-k}{2}\right)}{\Gamma\left(\eta+\frac{d-1}{2}\right)}\right]^{-1} -|\mathbf{R}|^{\eta-1}.\]

If $\eta = 1$, then the LKJ distribution is uniform over the space of correlation matrices.

Note

if a Cholesky factor of the correlation matrix is desired, it is more efficient to use LKJCholesky, which avoids factorizing the matrix.

source

Internal Methods (for creating your own matrix-variate distributions)

Missing docstring.

Missing docstring for Distributions._logpdf(d::MatrixDistribution, x::AbstractMatrix{<:Real}). Check Documenter's build log for details.

Index

+|\mathbf{R}|^{\eta-1}.\]

If $\eta = 1$, then the LKJ distribution is uniform over the space of correlation matrices.

Note

if a Cholesky factor of the correlation matrix is desired, it is more efficient to use LKJCholesky, which avoids factorizing the matrix.

source

Internal Methods (for creating your own matrix-variate distributions)

Missing docstring.

Missing docstring for Distributions._logpdf(d::MatrixDistribution, x::AbstractMatrix{<:Real}). Check Documenter's build log for details.

Index

diff --git a/previews/PR1908/mixture/index.html b/previews/PR1908/mixture/index.html index d9ffbf1a8..87c835c50 100644 --- a/previews/PR1908/mixture/index.html +++ b/previews/PR1908/mixture/index.html @@ -7,7 +7,7 @@ end const UnivariateMixture = AbstractMixtureModel{Univariate} -const MultivariateMixture = AbstractMixtureModel{Multivariate}

Remarks:

Distributions.AbstractMixtureModelType

All subtypes of AbstractMixtureModel should implement the following methods:

  • ncomponents(d): the number of components

  • component(d, k): return the k-th component

  • probs(d): return a vector of prior probabilities over components.

source

With such a type system, the type for a mixture of univariate normal distributions can be written as

MixtureModel{Univariate,Continuous,Normal}

Constructors

Distributions.MixtureModelType

MixtureModel{VF<:VariateForm,VS<:ValueSupport,C<:Distribution,CT<:Real} A mixture of distributions, parametrized on:

  • VF,VS variate and support
  • C distribution family of the mixture
  • CT the type for probabilities of the prior
source

Examples

# constructs a mixture of three normal distributions,
+const MultivariateMixture  = AbstractMixtureModel{Multivariate}

Remarks:

Distributions.AbstractMixtureModelType

All subtypes of AbstractMixtureModel should implement the following methods:

  • ncomponents(d): the number of components

  • component(d, k): return the k-th component

  • probs(d): return a vector of prior probabilities over components.

source

With such a type system, the type for a mixture of univariate normal distributions can be written as

MixtureModel{Univariate,Continuous,Normal}

Constructors

Distributions.MixtureModelType

MixtureModel{VF<:VariateForm,VS<:ValueSupport,C<:Distribution,CT<:Real} A mixture of distributions, parametrized on:

  • VF,VS variate and support
  • C distribution family of the mixture
  • CT the type for probabilities of the prior
source

Examples

# constructs a mixture of three normal distributions,
 # with prior probabilities [0.2, 0.5, 0.3]
 MixtureModel(Normal[
    Normal(-2.0, 1.2),
@@ -28,4 +28,4 @@
 
 # The following example shows how one can make a Gaussian mixture
 # where all components share the same unit variance
-MixtureModel(map(u -> Normal(u, 1.0), [-2.0, 0.0, 3.0]))

Common Interface

All subtypes of AbstractMixtureModel (obviously including MixtureModel) provide the following two methods:

Distributions.componentsMethod
components(d::AbstractMixtureModel)

Get a list of components of the mixture model d.

source
Distributions.probsMethod
probs(d::AbstractMixtureModel)

Get the vector of prior probabilities of all components of d.

source
Distributions.component_typeMethod
component_type(d::AbstractMixtureModel)

The type of the components of d.

source

In addition, for all subtypes of UnivariateMixture and MultivariateMixture, the following generic methods are provided:

Statistics.meanMethod
mean(d::Union{UnivariateMixture, MultivariateMixture})

Compute the overall mean (expectation).

source
Statistics.varMethod
var(d::UnivariateMixture)

Compute the overall variance (only for UnivariateMixture).

source
Base.lengthMethod
length(d::MultivariateMixture)

The length of each sample (only for Multivariate).

source
Distributions.pdfMethod
pdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
Distributions.logpdfMethod
logpdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the logarithm of the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
Base.randMethod
rand(d::Union{UnivariateMixture, MultivariateMixture})

Draw a sample from the mixture model d.

rand(d::Union{UnivariateMixture, MultivariateMixture}, n)

Draw n samples from d.

source
Random.rand!Method
rand!(d::Union{UnivariateMixture, MultivariateMixture}, r::AbstractArray)

Draw multiple samples from d and write them to r.

source

Estimation

There are several methods for the estimation of mixture models from data, and this problem remains an open research topic. This package does not provide facilities for estimating mixture models. One can resort to other packages, e.g. GaussianMixtures.jl, for this purpose.

+MixtureModel(map(u -> Normal(u, 1.0), [-2.0, 0.0, 3.0]))

Common Interface

All subtypes of AbstractMixtureModel (obviously including MixtureModel) provide the following two methods:

Distributions.componentsMethod
components(d::AbstractMixtureModel)

Get a list of components of the mixture model d.

source
Distributions.probsMethod
probs(d::AbstractMixtureModel)

Get the vector of prior probabilities of all components of d.

source
Distributions.component_typeMethod
component_type(d::AbstractMixtureModel)

The type of the components of d.

source

In addition, for all subtypes of UnivariateMixture and MultivariateMixture, the following generic methods are provided:

Statistics.meanMethod
mean(d::Union{UnivariateMixture, MultivariateMixture})

Compute the overall mean (expectation).

source
Statistics.varMethod
var(d::UnivariateMixture)

Compute the overall variance (only for UnivariateMixture).

source
Base.lengthMethod
length(d::MultivariateMixture)

The length of each sample (only for Multivariate).

source
Distributions.pdfMethod
pdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
Distributions.logpdfMethod
logpdf(d::Union{UnivariateMixture, MultivariateMixture}, x)

Evaluate the logarithm of the (mixed) probability density function over x. Here, x can be a single sample or an array of multiple samples.

source
Base.randMethod
rand(d::Union{UnivariateMixture, MultivariateMixture})

Draw a sample from the mixture model d.

rand(d::Union{UnivariateMixture, MultivariateMixture}, n)

Draw n samples from d.

source
Random.rand!Method
rand!(d::Union{UnivariateMixture, MultivariateMixture}, r::AbstractArray)

Draw multiple samples from d and write them to r.

source

Estimation

There are several methods for the estimation of mixture models from data, and this problem remains an open research topic. This package does not provide facilities for estimating mixture models. One can resort to other packages, e.g. GaussianMixtures.jl, for this purpose.

diff --git a/previews/PR1908/multivariate/index.html b/previews/PR1908/multivariate/index.html index 78eeadb03..e34e1107c 100644 --- a/previews/PR1908/multivariate/index.html +++ b/previews/PR1908/multivariate/index.html @@ -2,10 +2,10 @@ Multivariate Distributions · Distributions.jl

Multivariate Distributions

Multivariate distributions are the distributions whose variate forms are Multivariate (i.e each sample is a vector). Abstract types for multivariate distributions:

const MultivariateDistribution{S<:ValueSupport} = Distribution{Multivariate,S}
 
 const DiscreteMultivariateDistribution   = Distribution{Multivariate, Discrete}
-const ContinuousMultivariateDistribution = Distribution{Multivariate, Continuous}

Common Interface

The methods listed below are implemented for each multivariate distribution, which provides a consistent interface to work with multivariate distributions.

Computation of statistics

Base.lengthMethod
length(d::MultivariateDistribution) -> Int

Return the sample dimension of distribution d.

source
Base.sizeMethod
size(d::MultivariateDistribution)

Return the sample size of distribution d, i.e (length(d),).

source
Base.eltypeMethod
eltype(::Type{Sampleable})

The default element type of a sample. This is the type of elements of the samples generated by the rand method. However, one can provide an array of different element types to store the samples using rand!.

source
Statistics.meanMethod
mean(d::MultivariateDistribution)

Compute the mean vector of distribution d.

source
Statistics.varMethod
var(d::MultivariateDistribution)

Compute the vector of element-wise variances for distribution d.

source
Statistics.covMethod
cov(d::MultivariateDistribution)

Compute the covariance matrix for distribution d. (cor is provided based on cov).

source
Statistics.corMethod
cor(d::MultivariateDistribution)

Computes the correlation matrix for distribution d.

source
StatsBase.entropyMethod
entropy(d::MultivariateDistribution, b::Real)

Compute the entropy value of distribution $d$, w.r.t. a given base.

source

Probability evaluation

Distributions.insupportMethod
insupport(d::MultivariateDistribution, x::AbstractArray)

If $x$ is a vector, it returns whether x is within the support of $d$. If $x$ is a matrix, it returns whether every column in $x$ is within the support of $d$.

source
Missing docstring.

Missing docstring for pdf(::MultivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

Missing docstring.

Missing docstring for logpdf(::MultivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

StatsAPI.loglikelihoodMethod
loglikelihood(d::Distribution{ArrayLikeVariate{N}}, x) where {N}

The log-likelihood of distribution d with respect to all variate(s) contained in x.

Here, x can be any output of rand(d, dims...) and rand!(d, x). For instance, x can be

  • an array of dimension N with size(x) == size(d),
  • an array of dimension N + 1 with size(x)[1:N] == size(d), or
  • an array of arrays xi of dimension N with size(xi) == size(d).
source

Note: For multivariate distributions, the pdf value is usually very small or large, and therefore direct evaluation of the pdf may cause numerical problems. It is generally advisable to perform probability computation in log scale.

Sampling

Base.randMethod
rand(::AbstractRNG, ::Sampleable)

Samples from the sampler and returns the result.

source
Random.rand!Method
rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

Samples in-place from the sampler and stores the result in the provided array.

source

Note: In addition to these common methods, each multivariate distribution has its special methods, as introduced below.

Distributions

Distributions.MultinomialType

The Multinomial distribution generalizes the binomial distribution. Consider n independent draws from a Categorical distribution over a finite set of size k, and let $X = (X_1, ..., X_k)$ where $X_i$ represents the number of times the element $i$ occurs, then the distribution of $X$ is a multinomial distribution. Each sample of a multinomial distribution is a k-dimensional integer vector that sums to n.

The probability mass function is given by

\[f(x; n, p) = \frac{n!}{x_1! \cdots x_k!} \prod_{i=1}^k p_i^{x_i}, +const ContinuousMultivariateDistribution = Distribution{Multivariate, Continuous}

Common Interface

The methods listed below are implemented for each multivariate distribution, which provides a consistent interface to work with multivariate distributions.

Computation of statistics

Base.lengthMethod
length(d::MultivariateDistribution) -> Int

Return the sample dimension of distribution d.

source
Base.sizeMethod
size(d::MultivariateDistribution)

Return the sample size of distribution d, i.e (length(d),).

source
Base.eltypeMethod
eltype(::Type{Sampleable})

The default element type of a sample. This is the type of elements of the samples generated by the rand method. However, one can provide an array of different element types to store the samples using rand!.

source
Statistics.meanMethod
mean(d::MultivariateDistribution)

Compute the mean vector of distribution d.

source
Statistics.varMethod
var(d::MultivariateDistribution)

Compute the vector of element-wise variances for distribution d.

source
Statistics.covMethod
cov(d::MultivariateDistribution)

Compute the covariance matrix for distribution d. (cor is provided based on cov).

source
Statistics.corMethod
cor(d::MultivariateDistribution)

Computes the correlation matrix for distribution d.

source
StatsBase.entropyMethod
entropy(d::MultivariateDistribution, b::Real)

Compute the entropy value of distribution $d$, w.r.t. a given base.

source

Probability evaluation

Distributions.insupportMethod
insupport(d::MultivariateDistribution, x::AbstractArray)

If $x$ is a vector, it returns whether x is within the support of $d$. If $x$ is a matrix, it returns whether every column in $x$ is within the support of $d$.

source
Missing docstring.

Missing docstring for pdf(::MultivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

Missing docstring.

Missing docstring for logpdf(::MultivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

StatsAPI.loglikelihoodMethod
loglikelihood(d::Distribution{ArrayLikeVariate{N}}, x) where {N}

The log-likelihood of distribution d with respect to all variate(s) contained in x.

Here, x can be any output of rand(d, dims...) and rand!(d, x). For instance, x can be

  • an array of dimension N with size(x) == size(d),
  • an array of dimension N + 1 with size(x)[1:N] == size(d), or
  • an array of arrays xi of dimension N with size(xi) == size(d).
source

Note: For multivariate distributions, the pdf value is usually very small or large, and therefore direct evaluation of the pdf may cause numerical problems. It is generally advisable to perform probability computation in log scale.

Sampling

Base.randMethod
rand(::AbstractRNG, ::Sampleable)

Samples from the sampler and returns the result.

source
Random.rand!Method
rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

Samples in-place from the sampler and stores the result in the provided array.

source

Note: In addition to these common methods, each multivariate distribution has its special methods, as introduced below.

Distributions

Distributions.MultinomialType

The Multinomial distribution generalizes the binomial distribution. Consider n independent draws from a Categorical distribution over a finite set of size k, and let $X = (X_1, ..., X_k)$ where $X_i$ represents the number of times the element $i$ occurs, then the distribution of $X$ is a multinomial distribution. Each sample of a multinomial distribution is a k-dimensional integer vector that sums to n.

The probability mass function is given by

\[f(x; n, p) = \frac{n!}{x_1! \cdots x_k!} \prod_{i=1}^k p_i^{x_i}, \quad x_1 + \cdots + x_k = n\]

Multinomial(n, p)   # Multinomial distribution for n trials with probability vector p
 Multinomial(n, k)   # Multinomial distribution for n trials with equal probabilities
-                    # over 1:k
source
Distributions.AbstractMvNormalType

The Multivariate normal distribution is a multidimensional generalization of the normal distribution. The probability density function of a d-dimensional multivariate normal distribution with mean vector $\boldsymbol{\mu}$ and covariance matrix $\boldsymbol{\Sigma}$ is:

\[f(\mathbf{x}; \boldsymbol{\mu}, \boldsymbol{\Sigma}) = \frac{1}{(2 \pi)^{d/2} |\boldsymbol{\Sigma}|^{1/2}} + # over 1:k

source
Distributions.AbstractMvNormalType

The Multivariate normal distribution is a multidimensional generalization of the normal distribution. The probability density function of a d-dimensional multivariate normal distribution with mean vector $\boldsymbol{\mu}$ and covariance matrix $\boldsymbol{\Sigma}$ is:

\[f(\mathbf{x}; \boldsymbol{\mu}, \boldsymbol{\Sigma}) = \frac{1}{(2 \pi)^{d/2} |\boldsymbol{\Sigma}|^{1/2}} \exp \left( - \frac{1}{2} (\mathbf{x} - \boldsymbol{\mu})^T \Sigma^{-1} (\mathbf{x} - \boldsymbol{\mu}) \right)\]

We realize that the mean vector and the covariance often have special forms in practice, which can be exploited to simplify the computation. For example, the mean vector is sometimes just a zero vector, while the covariance matrix can be a diagonal matrix or even in the form of $\sigma^2 \mathbf{I}$. To take advantage of such special cases, we introduce a parametric type MvNormal, defined as below, which allows users to specify the special structure of the mean and covariance.

struct MvNormal{T<:Real,Cov<:AbstractPDMat,Mean<:AbstractVector} <: AbstractMvNormal
     μ::Mean
     Σ::Cov
@@ -17,7 +17,7 @@
 const ZeroMeanDiagNormal{Axes} = MvNormal{Float64, PDiagMat{Float64,Vector{Float64}}, Zeros{Float64,1,Axes}}
 const ZeroMeanFullNormal{Axes} = MvNormal{Float64, PDMat{Float64,Matrix{Float64}},    Zeros{Float64,1,Axes}}

Multivariate normal distributions support affine transformations:

d = MvNormal(μ, Σ)
 c + B * d    # == MvNormal(B * μ + c, B * Σ * B')
-dot(b, d)    # == Normal(dot(b, μ), b' * Σ * b)
source
Distributions.MvNormalType
MvNormal

Generally, users don't have to worry about these internal details.

We provide a common constructor MvNormal, which will construct a distribution of appropriate type depending on the input arguments.

source
Distributions.MvNormalCanonType
MvNormalCanon

The multivariate normal distribution is an exponential family distribution, with two canonical parameters: the potential vector $\mathbf{h}$ and the precision matrix $\mathbf{J}$. The relation between these parameters and the conventional representation (i.e. the one using mean $\boldsymbol{\mu}$ and covariance $\boldsymbol{\Sigma}$) is:

\[\mathbf{h} = \boldsymbol{\Sigma}^{-1} \boldsymbol{\mu}, \quad \text{ and } \quad \mathbf{J} = \boldsymbol{\Sigma}^{-1}\]

The canonical parameterization is widely used in Bayesian analysis. We provide a type MvNormalCanon, which is also a subtype of AbstractMvNormal to represent a multivariate normal distribution using canonical parameters. Particularly, MvNormalCanon is defined as:

struct MvNormalCanon{T<:Real,P<:AbstractPDMat,V<:AbstractVector} <: AbstractMvNormal
+dot(b, d)    # == Normal(dot(b, μ), b' * Σ * b)
source
Distributions.MvNormalType
MvNormal

Generally, users don't have to worry about these internal details.

We provide a common constructor MvNormal, which will construct a distribution of appropriate type depending on the input arguments.

source
Distributions.MvNormalCanonType
MvNormalCanon

The multivariate normal distribution is an exponential family distribution, with two canonical parameters: the potential vector $\mathbf{h}$ and the precision matrix $\mathbf{J}$. The relation between these parameters and the conventional representation (i.e. the one using mean $\boldsymbol{\mu}$ and covariance $\boldsymbol{\Sigma}$) is:

\[\mathbf{h} = \boldsymbol{\Sigma}^{-1} \boldsymbol{\mu}, \quad \text{ and } \quad \mathbf{J} = \boldsymbol{\Sigma}^{-1}\]

The canonical parameterization is widely used in Bayesian analysis. We provide a type MvNormalCanon, which is also a subtype of AbstractMvNormal to represent a multivariate normal distribution using canonical parameters. Particularly, MvNormalCanon is defined as:

struct MvNormalCanon{T<:Real,P<:AbstractPDMat,V<:AbstractVector} <: AbstractMvNormal
     μ::V    # the mean vector
     h::V    # potential vector, i.e. inv(Σ) * μ
     J::P    # precision matrix, i.e. inv(Σ)
@@ -27,12 +27,12 @@
 
 const ZeroMeanFullNormalCanon{Axes} = MvNormalCanon{Float64, PDMat{Float64,Matrix{Float64}},    Zeros{Float64,1,Axes}}
 const ZeroMeanDiagNormalCanon{Axes} = MvNormalCanon{Float64, PDiagMat{Float64,Vector{Float64}}, Zeros{Float64,1,Axes}}
-const ZeroMeanIsoNormalCanon{Axes}  = MvNormalCanon{Float64, ScalMat{Float64},                  Zeros{Float64,1,Axes}}

Note: MvNormalCanon share the same set of methods as MvNormal.

source
Distributions.MvLogitNormalType
MvLogitNormal{<:AbstractMvNormal}

The multivariate logit-normal distribution is a multivariate generalization of LogitNormal capable of handling correlations between variables.

If $\mathbf{y} \sim \mathrm{MvNormal}(\boldsymbol{\mu}, \boldsymbol{\Sigma})$ is a length $d-1$ vector, then

\[\mathbf{x} = \operatorname{softmax}\left(\begin{bmatrix}\mathbf{y} \\ 0 \end{bmatrix}\right) \sim \mathrm{MvLogitNormal}(\boldsymbol{\mu}, \boldsymbol{\Sigma})\]

is a length $d$ probability vector.

MvLogitNormal(μ, Σ)                 # MvLogitNormal with y ~ MvNormal(μ, Σ)
+const ZeroMeanIsoNormalCanon{Axes}  = MvNormalCanon{Float64, ScalMat{Float64},                  Zeros{Float64,1,Axes}}

Note: MvNormalCanon share the same set of methods as MvNormal.

source
Distributions.MvLogitNormalType
MvLogitNormal{<:AbstractMvNormal}

The multivariate logit-normal distribution is a multivariate generalization of LogitNormal capable of handling correlations between variables.

If $\mathbf{y} \sim \mathrm{MvNormal}(\boldsymbol{\mu}, \boldsymbol{\Sigma})$ is a length $d-1$ vector, then

\[\mathbf{x} = \operatorname{softmax}\left(\begin{bmatrix}\mathbf{y} \\ 0 \end{bmatrix}\right) \sim \mathrm{MvLogitNormal}(\boldsymbol{\mu}, \boldsymbol{\Sigma})\]

is a length $d$ probability vector.

MvLogitNormal(μ, Σ)                 # MvLogitNormal with y ~ MvNormal(μ, Σ)
 MvLogitNormal(MvNormal(μ, Σ))       # same as above
-MvLogitNormal(MvNormalCanon(μ, J))  # MvLogitNormal with y ~ MvNormalCanon(μ, J)

Fields

  • normal::AbstractMvNormal: contains the $d-1$-dimensional distribution of $y$
source
Distributions.MvLogNormalType
MvLogNormal(d::MvNormal)

The Multivariate lognormal distribution is a multidimensional generalization of the lognormal distribution.

If $\boldsymbol X \sim \mathcal{N}(\boldsymbol\mu,\,\boldsymbol\Sigma)$ has a multivariate normal distribution then $\boldsymbol Y=\exp(\boldsymbol X)$ has a multivariate lognormal distribution.

Mean vector $\boldsymbol{\mu}$ and covariance matrix $\boldsymbol{\Sigma}$ of the underlying normal distribution are known as the location and scale parameters of the corresponding lognormal distribution.

source
Distributions.DirichletType
Dirichlet

The Dirichlet distribution is often used as the conjugate prior for Categorical or Multinomial distributions. The probability density function of a Dirichlet distribution with parameter $\alpha = (\alpha_1, \ldots, \alpha_k)$ is:

\[f(x; \alpha) = \frac{1}{B(\alpha)} \prod_{i=1}^k x_i^{\alpha_i - 1}, \quad \text{ with } +MvLogitNormal(MvNormalCanon(μ, J)) # MvLogitNormal with y ~ MvNormalCanon(μ, J)

Fields

  • normal::AbstractMvNormal: contains the $d-1$-dimensional distribution of $y$
source
Distributions.MvLogNormalType
MvLogNormal(d::MvNormal)

The Multivariate lognormal distribution is a multidimensional generalization of the lognormal distribution.

If $\boldsymbol X \sim \mathcal{N}(\boldsymbol\mu,\,\boldsymbol\Sigma)$ has a multivariate normal distribution then $\boldsymbol Y=\exp(\boldsymbol X)$ has a multivariate lognormal distribution.

Mean vector $\boldsymbol{\mu}$ and covariance matrix $\boldsymbol{\Sigma}$ of the underlying normal distribution are known as the location and scale parameters of the corresponding lognormal distribution.

source
Distributions.DirichletType
Dirichlet

The Dirichlet distribution is often used as the conjugate prior for Categorical or Multinomial distributions. The probability density function of a Dirichlet distribution with parameter $\alpha = (\alpha_1, \ldots, \alpha_k)$ is:

\[f(x; \alpha) = \frac{1}{B(\alpha)} \prod_{i=1}^k x_i^{\alpha_i - 1}, \quad \text{ with } B(\alpha) = \frac{\prod_{i=1}^k \Gamma(\alpha_i)}{\Gamma \left( \sum_{i=1}^k \alpha_i \right)}, \quad x_1 + \cdots + x_k = 1\]

# Let alpha be a vector
 Dirichlet(alpha)         # Dirichlet distribution with parameter vector alpha
 
 # Let a be a positive scalar
-Dirichlet(k, a)          # Dirichlet distribution with parameter a * ones(k)
source
Distributions.ProductType
Product <: MultivariateDistribution

An N dimensional MultivariateDistribution constructed from a vector of N independent UnivariateDistributions.

Product(Uniform.(rand(10), 1)) # A 10-dimensional Product from 10 independent `Uniform` distributions.
source

Addition Methods

AbstractMvNormal

In addition to the methods listed in the common interface above, we also provide the following methods for all multivariate distributions under the base type AbstractMvNormal:

Distributions.sqmahalMethod
sqmahal(d, x)

Return the squared Mahalanobis distance from x to the center of d, w.r.t. the covariance. When x is a vector, it returns a scalar value. When x is a matrix, it returns a vector of length size(x,2).

sqmahal!(r, d, x) with write the results to a pre-allocated array r.

source
Base.randMethod
rand(::AbstractRNG, ::Distributions.AbstractMvNormal)

Sample a random vector from the provided multi-variate normal distribution.

source
Base.minimumMethod
minimum(d::Distribution)

Return the minimum of the support of d.

source
Base.maximumMethod
maximum(d::Distribution)

Return the maximum of the support of d.

source
Base.extremaMethod
extrema(d::Distribution)

Return the minimum and maximum of the support of d as a 2-tuple.

source

MvLogNormal

In addition to the methods listed in the common interface above, we also provide the following methods:

Distributions.locationMethod
location(d::MvLogNormal)

Return the location vector of the distribution (the mean of the underlying normal distribution).

source
Distributions.scaleMethod
scale(d::MvLogNormal)

Return the scale matrix of the distribution (the covariance matrix of the underlying normal distribution).

source
Statistics.medianMethod
median(d::MvLogNormal)

Return the median vector of the lognormal distribution. which is strictly smaller than the mean.

source
StatsBase.modeMethod
mode(d::MvLogNormal)

Return the mode vector of the lognormal distribution, which is strictly smaller than the mean and median.

source

It can be necessary to calculate the parameters of the lognormal (location vector and scale matrix) from a given covariance and mean, median or mode. To that end, the following functions are provided.

Distributions.locationMethod
location{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix)

Calculate the location vector (the mean of the underlying normal distribution).

  • If s == :meancov, then m is taken as the mean, and S the covariance matrix of a lognormal distribution.
  • If s == :mean | :median | :mode, then m is taken as the mean, median or mode of the lognormal respectively, and S is interpreted as the scale matrix (the covariance of the underlying normal distribution).

It is not possible to analytically calculate the location vector from e.g., median + covariance, or from mode + covariance.

source
Distributions.location!Method
location!{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix,μ::AbstractVector)

Calculate the location vector (as above) and store the result in $μ$

source
Distributions.scaleMethod
scale{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix)

Calculate the scale parameter, as defined for the location parameter above.

source
Distributions.scale!Method
scale!{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix,Σ::AbstractMatrix)

Calculate the scale parameter, as defined for the location parameter above and store the result in Σ.

source
StatsAPI.paramsMethod
params{D<:AbstractMvLogNormal}(::Type{D},m::AbstractVector,S::AbstractMatrix)

Return (scale,location) for a given mean and covariance

source

Internal Methods (for creating your own multivariate distribution)

Missing docstring.

Missing docstring for Distributions._logpdf(d::MultivariateDistribution, x::AbstractArray). Check Documenter's build log for details.

Product distributions

Distributions.product_distributionFunction
product_distribution(dists::AbstractArray{<:Distribution{<:ArrayLikeVariate{M}},N})

Create a distribution of M + N-dimensional arrays as a product distribution of independent M-dimensional distributions by stacking them.

The function falls back to constructing a ProductDistribution distribution but specialized methods can be defined.

source
product_distribution(dists::AbstractVector{<:Normal})

Create a multivariate normal distribution by stacking the univariate normal distributions.

The resulting distribution of type MvNormal has a diagonal covariance matrix.

source

Using product_distribution is advised to construct product distributions. For some distributions, it constructs a special multivariate type.

Index

+Dirichlet(k, a) # Dirichlet distribution with parameter a * ones(k)source
Distributions.ProductType
Product <: MultivariateDistribution

An N dimensional MultivariateDistribution constructed from a vector of N independent UnivariateDistributions.

Product(Uniform.(rand(10), 1)) # A 10-dimensional Product from 10 independent `Uniform` distributions.
source

Addition Methods

AbstractMvNormal

In addition to the methods listed in the common interface above, we also provide the following methods for all multivariate distributions under the base type AbstractMvNormal:

Distributions.invcovMethod
invcov(d::AbstractMvNormal)

Return the inversed covariance matrix of d.

source
Distributions.logdetcovMethod
logdetcov(d::AbstractMvNormal)

Return the log-determinant value of the covariance matrix.

source
Distributions.sqmahalMethod
sqmahal(d, x)

Return the squared Mahalanobis distance from x to the center of d, w.r.t. the covariance. When x is a vector, it returns a scalar value. When x is a matrix, it returns a vector of length size(x,2).

sqmahal!(r, d, x) with write the results to a pre-allocated array r.

source
Base.randMethod
rand(::AbstractRNG, ::Distributions.AbstractMvNormal)

Sample a random vector from the provided multi-variate normal distribution.

source
Base.minimumMethod
minimum(d::Distribution)

Return the minimum of the support of d.

source
Base.maximumMethod
maximum(d::Distribution)

Return the maximum of the support of d.

source
Base.extremaMethod
extrema(d::Distribution)

Return the minimum and maximum of the support of d as a 2-tuple.

source

MvLogNormal

In addition to the methods listed in the common interface above, we also provide the following methods:

Distributions.locationMethod
location(d::MvLogNormal)

Return the location vector of the distribution (the mean of the underlying normal distribution).

source
Distributions.scaleMethod
scale(d::MvLogNormal)

Return the scale matrix of the distribution (the covariance matrix of the underlying normal distribution).

source
Statistics.medianMethod
median(d::MvLogNormal)

Return the median vector of the lognormal distribution. which is strictly smaller than the mean.

source
StatsBase.modeMethod
mode(d::MvLogNormal)

Return the mode vector of the lognormal distribution, which is strictly smaller than the mean and median.

source

It can be necessary to calculate the parameters of the lognormal (location vector and scale matrix) from a given covariance and mean, median or mode. To that end, the following functions are provided.

Distributions.locationMethod
location{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix)

Calculate the location vector (the mean of the underlying normal distribution).

  • If s == :meancov, then m is taken as the mean, and S the covariance matrix of a lognormal distribution.
  • If s == :mean | :median | :mode, then m is taken as the mean, median or mode of the lognormal respectively, and S is interpreted as the scale matrix (the covariance of the underlying normal distribution).

It is not possible to analytically calculate the location vector from e.g., median + covariance, or from mode + covariance.

source
Distributions.location!Method
location!{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix,μ::AbstractVector)

Calculate the location vector (as above) and store the result in $μ$

source
Distributions.scaleMethod
scale{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix)

Calculate the scale parameter, as defined for the location parameter above.

source
Distributions.scale!Method
scale!{D<:AbstractMvLogNormal}(::Type{D},s::Symbol,m::AbstractVector,S::AbstractMatrix,Σ::AbstractMatrix)

Calculate the scale parameter, as defined for the location parameter above and store the result in Σ.

source
StatsAPI.paramsMethod
params{D<:AbstractMvLogNormal}(::Type{D},m::AbstractVector,S::AbstractMatrix)

Return (scale,location) for a given mean and covariance

source

Internal Methods (for creating your own multivariate distribution)

Missing docstring.

Missing docstring for Distributions._logpdf(d::MultivariateDistribution, x::AbstractArray). Check Documenter's build log for details.

Product distributions

Distributions.product_distributionFunction
product_distribution(dists::AbstractArray{<:Distribution{<:ArrayLikeVariate{M}},N})

Create a distribution of M + N-dimensional arrays as a product distribution of independent M-dimensional distributions by stacking them.

The function falls back to constructing a ProductDistribution distribution but specialized methods can be defined.

source
product_distribution(dists::AbstractVector{<:Normal})

Create a multivariate normal distribution by stacking the univariate normal distributions.

The resulting distribution of type MvNormal has a diagonal covariance matrix.

source

Using product_distribution is advised to construct product distributions. For some distributions, it constructs a special multivariate type.

Index

diff --git a/previews/PR1908/order_statistics/index.html b/previews/PR1908/order_statistics/index.html index 06cd8d53b..fb49ea528 100644 --- a/previews/PR1908/order_statistics/index.html +++ b/previews/PR1908/order_statistics/index.html @@ -1,11 +1,11 @@ Order Statistics · Distributions.jl

Order Statistics

The $i$th Order Statistic of a random sample of size $n$ from a univariate distribution is the $i$th element after sorting in increasing order. As a special case, the first and $n$th order statistics are the minimum and maximum of the sample, while for odd $n$, the $\lceil \frac{n}{2} \rceil$th entry is the sample median.

Given any univariate distribution and the sample size $n$, we can construct the distribution of its $i$th order statistic:

Distributions.OrderStatisticType
OrderStatistic{D<:UnivariateDistribution,S<:ValueSupport} <: UnivariateDistribution{S}

The distribution of an order statistic from IID samples from a univariate distribution.

OrderStatistic(dist::UnivariateDistribution, n::Int, rank::Int; check_args::Bool=true)

Construct the distribution of the rank $=i$th order statistic from n independent samples from dist.

The $i$th order statistic of a sample is the $i$th element of the sorted sample. For example, the 1st order statistic is the sample minimum, while the $n$th order statistic is the sample maximum.

If $f$ is the probability density (mass) function of dist with distribution function $F$, then the probability density function $g$ of the order statistic for continuous dist is

\[g(x; n, i) = {n \choose i} [F(x)]^{i-1} [1 - F(x)]^{n-i} f(x),\]

and the probability mass function $g$ of the order statistic for discrete dist is

\[g(x; n, i) = \sum_{k=i}^n {n \choose k} \left( [F(x)]^k [1 - F(x)]^{n-k} - [F(x_-)]^k [1 - F(x_-)]^{n-k} \right),\]

where $x_-$ is the largest element in the support of dist less than $x$.

For the joint distribution of a subset of order statistics, use JointOrderStatistics instead.

Examples

OrderStatistic(Cauchy(), 10, 1)              # distribution of the sample minimum
 OrderStatistic(DiscreteUniform(10), 10, 10)  # distribution of the sample maximum
-OrderStatistic(Gamma(1, 1), 11, 5)           # distribution of the sample median
source

If we are interested in more than one order statistic, for continuous univariate distributions we can also construct the joint distribution of order statistics:

Distributions.JointOrderStatisticsType
JointOrderStatistics <: ContinuousMultivariateDistribution

The joint distribution of a subset of order statistics from a sample from a continuous univariate distribution.

JointOrderStatistics(
+OrderStatistic(Gamma(1, 1), 11, 5)           # distribution of the sample median
source

If we are interested in more than one order statistic, for continuous univariate distributions we can also construct the joint distribution of order statistics:

Distributions.JointOrderStatisticsType
JointOrderStatistics <: ContinuousMultivariateDistribution

The joint distribution of a subset of order statistics from a sample from a continuous univariate distribution.

JointOrderStatistics(
     dist::ContinuousUnivariateDistribution,
     n::Int,
     ranks=Base.OneTo(n);
     check_args::Bool=true,
 )

Construct the joint distribution of order statistics for the specified ranks from an IID sample of size n from dist.

The $i$th order statistic of a sample is the $i$th element of the sorted sample. For example, the 1st order statistic is the sample minimum, while the $n$th order statistic is the sample maximum.

ranks must be a sorted vector or tuple of unique Ints between 1 and n.

For a single order statistic, use OrderStatistic instead.

Examples

JointOrderStatistics(Normal(), 10)           # Product(fill(Normal(), 10)) restricted to ordered vectors
 JointOrderStatistics(Cauchy(), 10, 2:9)      # joint distribution of all but the extrema
-JointOrderStatistics(Cauchy(), 10, (1, 10))  # joint distribution of only the extrema
source
+JointOrderStatistics(Cauchy(), 10, (1, 10)) # joint distribution of only the extremasource diff --git a/previews/PR1908/reshape/index.html b/previews/PR1908/reshape/index.html index aef52bf74..02a8cb1df 100644 --- a/previews/PR1908/reshape/index.html +++ b/previews/PR1908/reshape/index.html @@ -1,3 +1,3 @@ Reshaping distributions · Distributions.jl

Reshaping distributions

Distributions of array variates such as MultivariateDistributions and MatrixDistributions can be reshaped.

Base.reshapeFunction
reshape(d::Distribution{<:ArrayLikeVariate}, dims::Int...)
-reshape(d::Distribution{<:ArrayLikeVariate}, dims::Dims)

Return a Distribution of reshape(X, dims) where X is a random variable with distribution d.

The default implementation returns a ReshapedDistribution. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use reshape instead of the constructor of ReshapedDistribution.

Implementation

Since reshape(d, dims::Int...) calls reshape(d, dims::Dims), one should implement reshape(d, ::Dims) for desired distributions d.

See also: vec

source
Base.vecFunction
vec(d::Distribution{<:ArrayLikeVariate})

Return a MultivariateDistribution of vec(X) where X is a random variable with distribution d.

The default implementation returns a ReshapedDistribution. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use vec instead of the constructor of ReshapedDistribution.

Implementation

Since vec(d) is defined as reshape(d, length(d)) one should implement reshape(d, ::Tuple{Int}) rather than vec.

See also: reshape

source
+reshape(d::Distribution{<:ArrayLikeVariate}, dims::Dims)

Return a Distribution of reshape(X, dims) where X is a random variable with distribution d.

The default implementation returns a ReshapedDistribution. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use reshape instead of the constructor of ReshapedDistribution.

Implementation

Since reshape(d, dims::Int...) calls reshape(d, dims::Dims), one should implement reshape(d, ::Dims) for desired distributions d.

See also: vec

source
Base.vecFunction
vec(d::Distribution{<:ArrayLikeVariate})

Return a MultivariateDistribution of vec(X) where X is a random variable with distribution d.

The default implementation returns a ReshapedDistribution. However, it can return more optimized distributions for specific types of distributions and numbers of dimensions. Therefore it is recommended to use vec instead of the constructor of ReshapedDistribution.

Implementation

Since vec(d) is defined as reshape(d, length(d)) one should implement reshape(d, ::Tuple{Int}) rather than vec.

See also: reshape

source
diff --git a/previews/PR1908/search/index.html b/previews/PR1908/search/index.html index 94c532e3f..fca2cfff1 100644 --- a/previews/PR1908/search/index.html +++ b/previews/PR1908/search/index.html @@ -1,2 +1,2 @@ -Search · Distributions.jl

Loading search...

    +Search · Distributions.jl

    Loading search...

      diff --git a/previews/PR1908/starting/index.html b/previews/PR1908/starting/index.html index d519083a1..e8170691b 100644 --- a/previews/PR1908/starting/index.html +++ b/previews/PR1908/starting/index.html @@ -17,4 +17,4 @@ 2-element Array{Symbol,1}: :μ :β

      This tells you that a Cauchy distribution is initialized with location μ and scale β.

      Estimate the Parameters

      It is often useful to approximate an empirical distribution with a theoretical distribution. As an example, we can use the array x we created above and ask which normal distribution best describes it:

      julia> fit(Normal, x)
      -Normal(μ=0.036692077201688635, σ=1.1228280164716382)

      Since x is a random draw from Normal, it's easy to check that the fitted values are sensible. Indeed, the estimates [0.04, 1.12] are close to the true values of [0.0, 1.0] that we used to generate x.

      +Normal(μ=0.036692077201688635, σ=1.1228280164716382)

      Since x is a random draw from Normal, it's easy to check that the fitted values are sensible. Indeed, the estimates [0.04, 1.12] are close to the true values of [0.0, 1.0] that we used to generate x.

      diff --git a/previews/PR1908/truncate/index.html b/previews/PR1908/truncate/index.html index c01f6aabd..4c256647b 100644 --- a/previews/PR1908/truncate/index.html +++ b/previews/PR1908/truncate/index.html @@ -3,4 +3,4 @@ truncated(d0::UnivariateDistribution, lower::Real, upper::Real)

      A truncated distribution d of a distribution d0 to the interval $[l, u]=$[lower, upper] has the probability density (mass) function:

      \[f(x; d_0, l, u) = \frac{f_{d_0}(x)}{P_{Z \sim d_0}(l \le Z \le u)}, \quad x \in [l, u],\]

      where $f_{d_0}(x)$ is the probability density (mass) function of $d_0$.

      The function throws an error if $l > u$.

      truncated(d0; lower=l)           # d0 left-truncated to the interval [l, Inf)
       truncated(d0; upper=u)           # d0 right-truncated to the interval (-Inf, u]
       truncated(d0; lower=l, upper=u)  # d0 truncated to the interval [l, u]
      -truncated(d0, l, u)              # d0 truncated to the interval [l, u]

      The function falls back to constructing a Truncated wrapper.

      Implementation

      To implement a specialized truncated form for distributions of type D, one or more of the following methods should be implemented:

      source

      In the general case, this will create a Truncated{typeof(d)} structure, defined as follows:

      Distributions.TruncatedType
      Truncated

      Generic wrapper for a truncated distribution.

      The truncated normal distribution is a particularly important one in the family of truncated distributions. Unlike the general case, truncated normal distributions support mean, mode, modes, var, std, and entropy.

      source

      Many functions, including those for the evaluation of pdf and sampling, are defined for all truncated univariate distributions:

      Functions to compute statistics, such as mean, mode, var, std, and entropy, are not available for generic truncated distributions. Generally, there are no easy ways to compute such quantities due to the complications incurred by truncation. However, these methods are supported for truncated normal distributions Truncated{<:Normal} which can be constructed with truncated(::Normal, ...).

      +truncated(d0, l, u) # d0 truncated to the interval [l, u]

      The function falls back to constructing a Truncated wrapper.

      Implementation

      To implement a specialized truncated form for distributions of type D, one or more of the following methods should be implemented:

      source

      In the general case, this will create a Truncated{typeof(d)} structure, defined as follows:

      Distributions.TruncatedType
      Truncated

      Generic wrapper for a truncated distribution.

      The truncated normal distribution is a particularly important one in the family of truncated distributions. Unlike the general case, truncated normal distributions support mean, mode, modes, var, std, and entropy.

      source

      Many functions, including those for the evaluation of pdf and sampling, are defined for all truncated univariate distributions:

      Functions to compute statistics, such as mean, mode, var, std, and entropy, are not available for generic truncated distributions. Generally, there are no easy ways to compute such quantities due to the complications incurred by truncation. However, these methods are supported for truncated normal distributions Truncated{<:Normal} which can be constructed with truncated(::Normal, ...).

      diff --git a/previews/PR1908/types/index.html b/previews/PR1908/types/index.html index 3bd0b8035..2a11f9f46 100644 --- a/previews/PR1908/types/index.html +++ b/previews/PR1908/types/index.html @@ -1,6 +1,6 @@ Type Hierarchy · Distributions.jl

      Type Hierarchy

      All samplers and distributions provided in this package are organized into a type hierarchy described as follows.

      Sampleable

      The root of this type hierarchy is Sampleable. The abstract type Sampleable subsumes any types of objects from which one can draw samples, which particularly includes samplers and distributions. Formally, Sampleable is defined as

      abstract type Sampleable{F<:VariateForm,S<:ValueSupport} end

      It has two type parameters that define the kind of samples that can be drawn therefrom.

      Distributions.Sampleable
      -Base.rand(::Distributions.Sampleable)

      VariateForm

      Distributions.VariateForm

      The VariateForm subtypes defined in Distributions.jl are:

      TypeA single sampleMultiple samples
      Univariate == ArrayLikeVariate{0}a scalar numberA numeric array of arbitrary shape, each element being a sample
      Multivariate == ArrayLikeVariate{1}a numeric vectorA matrix, each column being a sample
      Matrixvariate == ArrayLikeVariate{2}a numeric matrixAn array of matrices, each element being a sample matrix

      ValueSupport

      The ValueSupport sub-types defined in Distributions.jl are:

      Distributions.DiscreteType
      Discrete <: ValueSupport

      This type represents the support of a discrete random variable.

      It is countable. For instance, it can be a finite set or a countably infinite set such as the natural numbers.

      See also: Continuous, ValueSupport

      source
      TypeDefault element typeDescriptionExamples
      DiscreteIntSamples take countably many values$\{0,1,2,3\}$, $\mathbb{N}$
      ContinuousFloat64Samples take uncountably many values$[0, 1]$, $\mathbb{R}$

      Multiple samples are often organized into an array, depending on the variate form.

      The basic functionalities that a sampleable object provides are to retrieve information about the samples it generates and to draw samples. Particularly, the following functions are provided for sampleable objects:

      Base.lengthMethod
      length(s::Sampleable)

      The length of each sample. Always returns 1 when s is univariate.

      source
      Base.sizeMethod
      size(s::Sampleable)

      The size (i.e. shape) of each sample. Always returns () when s is univariate, and (length(s),) when s is multivariate.

      source
      Distributions.nsamplesMethod
      nsamples(s::Sampleable)

      The number of values contained in one sample of s. Multiple samples are often organized into an array, depending on the variate form.

      source
      Base.eltypeMethod
      eltype(::Type{Sampleable})

      The default element type of a sample. This is the type of elements of the samples generated by the rand method. However, one can provide an array of different element types to store the samples using rand!.

      source
      Base.randMethod
      rand(::AbstractRNG, ::Sampleable)

      Samples from the sampler and returns the result.

      source
      Random.rand!Method
      rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

      Samples in-place from the sampler and stores the result in the provided array.

      source

      Distributions

      We use Distribution, a subtype of Sampleable as defined below, to capture probabilistic distributions. In addition to being sampleable, a distribution typically comes with an explicit way to combine its domain, probability density function, and many other quantities.

      abstract type Distribution{F<:VariateForm,S<:ValueSupport} <: Sampleable{F,S} end
      Distributions.Distribution

      To simplify the use in practice, we introduce a series of type alias as follows:

      const UnivariateDistribution{S<:ValueSupport}   = Distribution{Univariate,S}
      +Base.rand(::Distributions.Sampleable)

      VariateForm

      Distributions.VariateForm

      The VariateForm subtypes defined in Distributions.jl are:

      TypeA single sampleMultiple samples
      Univariate == ArrayLikeVariate{0}a scalar numberA numeric array of arbitrary shape, each element being a sample
      Multivariate == ArrayLikeVariate{1}a numeric vectorA matrix, each column being a sample
      Matrixvariate == ArrayLikeVariate{2}a numeric matrixAn array of matrices, each element being a sample matrix

      ValueSupport

      The ValueSupport sub-types defined in Distributions.jl are:

      Distributions.DiscreteType
      Discrete <: ValueSupport

      This type represents the support of a discrete random variable.

      It is countable. For instance, it can be a finite set or a countably infinite set such as the natural numbers.

      See also: Continuous, ValueSupport

      source
      TypeDefault element typeDescriptionExamples
      DiscreteIntSamples take countably many values$\{0,1,2,3\}$, $\mathbb{N}$
      ContinuousFloat64Samples take uncountably many values$[0, 1]$, $\mathbb{R}$

      Multiple samples are often organized into an array, depending on the variate form.

      The basic functionalities that a sampleable object provides are to retrieve information about the samples it generates and to draw samples. Particularly, the following functions are provided for sampleable objects:

      Base.lengthMethod
      length(s::Sampleable)

      The length of each sample. Always returns 1 when s is univariate.

      source
      Base.sizeMethod
      size(s::Sampleable)

      The size (i.e. shape) of each sample. Always returns () when s is univariate, and (length(s),) when s is multivariate.

      source
      Distributions.nsamplesMethod
      nsamples(s::Sampleable)

      The number of values contained in one sample of s. Multiple samples are often organized into an array, depending on the variate form.

      source
      Base.eltypeMethod
      eltype(::Type{Sampleable})

      The default element type of a sample. This is the type of elements of the samples generated by the rand method. However, one can provide an array of different element types to store the samples using rand!.

      source
      Base.randMethod
      rand(::AbstractRNG, ::Sampleable)

      Samples from the sampler and returns the result.

      source
      Random.rand!Method
      rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

      Samples in-place from the sampler and stores the result in the provided array.

      source

      Distributions

      We use Distribution, a subtype of Sampleable as defined below, to capture probabilistic distributions. In addition to being sampleable, a distribution typically comes with an explicit way to combine its domain, probability density function, and many other quantities.

      abstract type Distribution{F<:VariateForm,S<:ValueSupport} <: Sampleable{F,S} end
      Distributions.Distribution

      To simplify the use in practice, we introduce a series of type alias as follows:

      const UnivariateDistribution{S<:ValueSupport}   = Distribution{Univariate,S}
       const MultivariateDistribution{S<:ValueSupport} = Distribution{Multivariate,S}
       const MatrixDistribution{S<:ValueSupport}       = Distribution{Matrixvariate,S}
       const NonMatrixDistribution = Union{UnivariateDistribution, MultivariateDistribution}
      @@ -13,4 +13,4 @@
       const DiscreteMultivariateDistribution   = Distribution{Multivariate,  Discrete}
       const ContinuousMultivariateDistribution = Distribution{Multivariate,  Continuous}
       const DiscreteMatrixDistribution         = Distribution{Matrixvariate, Discrete}
      -const ContinuousMatrixDistribution       = Distribution{Matrixvariate, Continuous}

      All methods applicable to Sampleable also apply to Distribution. The API for distributions of different variate forms are different (refer to univariates, multivariates, and matrix for details).

      +const ContinuousMatrixDistribution = Distribution{Matrixvariate, Continuous}

      All methods applicable to Sampleable also apply to Distribution. The API for distributions of different variate forms are different (refer to univariates, multivariates, and matrix for details).

      diff --git a/previews/PR1908/univariate/index.html b/previews/PR1908/univariate/index.html index 7fd4f6022..499f1e310 100644 --- a/previews/PR1908/univariate/index.html +++ b/previews/PR1908/univariate/index.html @@ -2,7 +2,7 @@ Univariate Distributions · Distributions.jl

      Univariate Distributions

      Univariate distributions are the distributions whose variate forms are Univariate (i.e each sample is a scalar). Abstract types for univariate distributions:

      const UnivariateDistribution{S<:ValueSupport} = Distribution{Univariate,S}
       
       const DiscreteUnivariateDistribution   = Distribution{Univariate, Discrete}
      -const ContinuousUnivariateDistribution = Distribution{Univariate, Continuous}

      Common Interface

      A series of methods is implemented for each univariate distribution, which provides useful functionalities such as moment computation, pdf evaluation, and sampling (i.e. random number generation).

      Parameter Retrieval

      Note: params are defined for all univariate distributions, while other parameter retrieval methods are only defined for those distributions for which these parameters make sense. See below for details.

      StatsAPI.paramsMethod
      params(d::UnivariateDistribution)

      Return a tuple of parameters. Let d be a distribution of type D, then D(params(d)...) will construct exactly the same distribution as $d$.

      source

      For distributions for which success and failure have a meaning, the following methods are defined:

      Computation of statistics

      Base.maximumMethod
      maximum(d::Distribution)

      Return the maximum of the support of d.

      source
      Base.minimumMethod
      minimum(d::Distribution)

      Return the minimum of the support of d.

      source
      Base.extremaMethod
      extrema(d::Distribution)

      Return the minimum and maximum of the support of d as a 2-tuple.

      source
      Statistics.varMethod
      var(d::UnivariateDistribution)

      Compute the variance. (A generic std is provided as std(d) = sqrt(var(d)))

      source
      Statistics.stdMethod
      std(d::UnivariateDistribution)

      Return the standard deviation of distribution d, i.e. sqrt(var(d)).

      source
      Statistics.medianMethod
      median(d::UnivariateDistribution)

      Return the median value of distribution d. The median is the smallest x in the support of d for which cdf(d, x) ≥ 1/2. Corresponding to this definition as 1/2-quantile, a fallback is provided calling the quantile function.

      source
      StatsBase.kurtosisMethod
      kurtosis(d::Distribution, correction::Bool)

      Computes excess kurtosis by default. Proper kurtosis can be returned with correction=false

      source
      StatsBase.entropyMethod
      entropy(d::UnivariateDistribution, b::Real)

      Compute the entropy value of distribution d, w.r.t. a given base.

      source
      StatsBase.entropyMethod
      entropy(d::UnivariateDistribution, b::Real)

      Compute the entropy value of distribution d, w.r.t. a given base.

      source
      Distributions.cfMethod
      cf(d::UnivariateDistribution, t)

      Evaluate the characteristic function of distribution d.

      source
      Distributions.pdfsquaredL2normFunction
      pdfsquaredL2norm(d::Distribution)

      Return the square of the L2 norm of the probability density function $f(x)$ of the distribution d:

      \[\int_{S} f(x)^{2} \mathrm{d} x\]

      where $S$ is the support of $f(x)$.

      source

      Probability Evaluation

      Distributions.insupportMethod
      insupport(d::UnivariateDistribution, x::Any)

      When x is a scalar, it returns whether x is within the support of d (e.g., insupport(d, x) = minimum(d) <= x <= maximum(d)). When x is an array, it returns whether every element in x is within the support of d.

      Generic fallback methods are provided, but it is often the case that insupport can be done more efficiently, and a specialized insupport is thus desirable. You should also override this function if the support is composed of multiple disjoint intervals.

      source
      Distributions.logpdfMethod
      logpdf(d::UnivariateDistribution, x::Real)

      Evaluate the logarithm of probability density (mass) at x.

      See also: pdf.

      source
      Missing docstring.

      Missing docstring for loglikelihood(::UnivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

      Distributions.logcdfMethod
      logcdf(d::UnivariateDistribution, x::Real)

      The logarithm of the cumulative function value(s) evaluated at x, i.e. log(cdf(x)).

      source
      Distributions.logdiffcdfMethod
      logdiffcdf(d::UnivariateDistribution, x::Real, y::Real)

      The natural logarithm of the difference between the cumulative density function at x and y, i.e. log(cdf(x) - cdf(y)).

      source
      Distributions.ccdfMethod
      ccdf(d::UnivariateDistribution, x::Real)

      The complementary cumulative function evaluated at x, i.e. 1 - cdf(d, x).

      source
      Distributions.logccdfMethod
      logccdf(d::UnivariateDistribution, x::Real)

      The logarithm of the complementary cumulative function values evaluated at x, i.e. log(ccdf(x)).

      source
      Statistics.quantileMethod
      quantile(d::UnivariateDistribution, q::Real)

      Evaluate the (generalized) inverse cumulative distribution function at q.

      For a given 0 ≤ q ≤ 1, quantile(d, q) is the smallest value x in the support of d for which cdf(d, x) ≥ q.

      See also: cquantile, invlogcdf, and invlogccdf.

      source
      Distributions.invlogcdfMethod
      invlogcdf(d::UnivariateDistribution, lp::Real)

      The (generalized) inverse function of logcdf.

      For a given lp ≤ 0, invlogcdf(d, lp) is the smallest value x in the support of d for which logcdf(d, x) ≥ lp.

      source
      Distributions.invlogccdfMethod
      invlogccdf(d::UnivariateDistribution, lp::Real)

      The (generalized) inverse function of logccdf.

      For a given lp ≤ 0, invlogccdf(d, lp) is the smallest value x in the support of d for which logccdf(d, x) ≤ lp.

      source

      Sampling (Random number generation)

      Base.randMethod
      rand(rng::AbstractRNG, d::UnivariateDistribution)

      Generate a scalar sample from d. The general fallback is quantile(d, rand()).

      source
      Random.rand!Method
      rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

      Samples in-place from the sampler and stores the result in the provided array.

      source

      Continuous Distributions

      Distributions.ArcsineType
      Arcsine(a,b)

      The Arcsine distribution has probability density function

      \[f(x) = \frac{1}{\pi \sqrt{(x - a) (b - x)}}, \quad x \in [a, b]\]

      Arcsine()        # Arcsine distribution with support [0, 1]
      +const ContinuousUnivariateDistribution = Distribution{Univariate, Continuous}

      Common Interface

      A series of methods is implemented for each univariate distribution, which provides useful functionalities such as moment computation, pdf evaluation, and sampling (i.e. random number generation).

      Parameter Retrieval

      Note: params are defined for all univariate distributions, while other parameter retrieval methods are only defined for those distributions for which these parameters make sense. See below for details.

      StatsAPI.paramsMethod
      params(d::UnivariateDistribution)

      Return a tuple of parameters. Let d be a distribution of type D, then D(params(d)...) will construct exactly the same distribution as $d$.

      source

      For distributions for which success and failure have a meaning, the following methods are defined:

      Computation of statistics

      Base.maximumMethod
      maximum(d::Distribution)

      Return the maximum of the support of d.

      source
      Base.minimumMethod
      minimum(d::Distribution)

      Return the minimum of the support of d.

      source
      Base.extremaMethod
      extrema(d::Distribution)

      Return the minimum and maximum of the support of d as a 2-tuple.

      source
      Statistics.varMethod
      var(d::UnivariateDistribution)

      Compute the variance. (A generic std is provided as std(d) = sqrt(var(d)))

      source
      Statistics.stdMethod
      std(d::UnivariateDistribution)

      Return the standard deviation of distribution d, i.e. sqrt(var(d)).

      source
      Statistics.medianMethod
      median(d::UnivariateDistribution)

      Return the median value of distribution d. The median is the smallest x in the support of d for which cdf(d, x) ≥ 1/2. Corresponding to this definition as 1/2-quantile, a fallback is provided calling the quantile function.

      source
      StatsBase.kurtosisMethod
      kurtosis(d::Distribution, correction::Bool)

      Computes excess kurtosis by default. Proper kurtosis can be returned with correction=false

      source
      StatsBase.entropyMethod
      entropy(d::UnivariateDistribution, b::Real)

      Compute the entropy value of distribution d, w.r.t. a given base.

      source
      StatsBase.entropyMethod
      entropy(d::UnivariateDistribution, b::Real)

      Compute the entropy value of distribution d, w.r.t. a given base.

      source
      Distributions.cfMethod
      cf(d::UnivariateDistribution, t)

      Evaluate the characteristic function of distribution d.

      source
      Distributions.pdfsquaredL2normFunction
      pdfsquaredL2norm(d::Distribution)

      Return the square of the L2 norm of the probability density function $f(x)$ of the distribution d:

      \[\int_{S} f(x)^{2} \mathrm{d} x\]

      where $S$ is the support of $f(x)$.

      source

      Probability Evaluation

      Distributions.insupportMethod
      insupport(d::UnivariateDistribution, x::Any)

      When x is a scalar, it returns whether x is within the support of d (e.g., insupport(d, x) = minimum(d) <= x <= maximum(d)). When x is an array, it returns whether every element in x is within the support of d.

      Generic fallback methods are provided, but it is often the case that insupport can be done more efficiently, and a specialized insupport is thus desirable. You should also override this function if the support is composed of multiple disjoint intervals.

      source
      Distributions.logpdfMethod
      logpdf(d::UnivariateDistribution, x::Real)

      Evaluate the logarithm of probability density (mass) at x.

      See also: pdf.

      source
      Missing docstring.

      Missing docstring for loglikelihood(::UnivariateDistribution, ::AbstractArray). Check Documenter's build log for details.

      Distributions.logcdfMethod
      logcdf(d::UnivariateDistribution, x::Real)

      The logarithm of the cumulative function value(s) evaluated at x, i.e. log(cdf(x)).

      source
      Distributions.logdiffcdfMethod
      logdiffcdf(d::UnivariateDistribution, x::Real, y::Real)

      The natural logarithm of the difference between the cumulative density function at x and y, i.e. log(cdf(x) - cdf(y)).

      source
      Distributions.ccdfMethod
      ccdf(d::UnivariateDistribution, x::Real)

      The complementary cumulative function evaluated at x, i.e. 1 - cdf(d, x).

      source
      Distributions.logccdfMethod
      logccdf(d::UnivariateDistribution, x::Real)

      The logarithm of the complementary cumulative function values evaluated at x, i.e. log(ccdf(x)).

      source
      Statistics.quantileMethod
      quantile(d::UnivariateDistribution, q::Real)

      Evaluate the (generalized) inverse cumulative distribution function at q.

      For a given 0 ≤ q ≤ 1, quantile(d, q) is the smallest value x in the support of d for which cdf(d, x) ≥ q.

      See also: cquantile, invlogcdf, and invlogccdf.

      source
      Distributions.invlogcdfMethod
      invlogcdf(d::UnivariateDistribution, lp::Real)

      The (generalized) inverse function of logcdf.

      For a given lp ≤ 0, invlogcdf(d, lp) is the smallest value x in the support of d for which logcdf(d, x) ≥ lp.

      source
      Distributions.invlogccdfMethod
      invlogccdf(d::UnivariateDistribution, lp::Real)

      The (generalized) inverse function of logccdf.

      For a given lp ≤ 0, invlogccdf(d, lp) is the smallest value x in the support of d for which logccdf(d, x) ≤ lp.

      source

      Sampling (Random number generation)

      Base.randMethod
      rand(rng::AbstractRNG, d::UnivariateDistribution)

      Generate a scalar sample from d. The general fallback is quantile(d, rand()).

      source
      Random.rand!Method
      rand!(::AbstractRNG, ::Sampleable, ::AbstractArray)

      Samples in-place from the sampler and stores the result in the provided array.

      source

      Continuous Distributions

      Distributions.ArcsineType
      Arcsine(a,b)

      The Arcsine distribution has probability density function

      \[f(x) = \frac{1}{\pi \sqrt{(x - a) (b - x)}}, \quad x \in [a, b]\]

      Arcsine()        # Arcsine distribution with support [0, 1]
       Arcsine(b)       # Arcsine distribution with support [0, b]
       Arcsine(a, b)    # Arcsine distribution with support [a, b]
       
      @@ -10,691 +10,691 @@
       minimum(d)       # Get the lower bound, i.e. a
       maximum(d)       # Get the upper bound, i.e. b
       location(d)      # Get the left bound, i.e. a
      -scale(d)         # Get the span of the support, i.e. b - a

      External links

      Use Arcsine(a, b, check_args=false) to bypass argument checks.

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 2 - + 4 - + 6 - + 8 - + 10 - + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + Arcsine(0, 1) - + x - + density - + '/>
      Distributions.BetaType
      Beta(α, β)

      The Beta distribution has probability density function

      \[f(x; \alpha, \beta) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1} (1 - x)^{\beta - 1}, \quad x \in [0, 1]\]

      The Beta distribution is related to the Gamma distribution via the property that if $X \sim \operatorname{Gamma}(\alpha)$ and $Y \sim \operatorname{Gamma}(\beta)$ independently, then $X / (X + Y) \sim \operatorname{Beta}(\alpha, \beta)$.

      Beta()        # equivalent to Beta(1, 1)
       Beta(α)       # equivalent to Beta(α, α)
       Beta(α, β)    # Beta distribution with shape parameters α and β
       
      -params(d)     # Get the parameters, i.e. (α, β)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 1.2 - + 1.4 - + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + Beta(2, 2) - + x - + density - + '/>
      Distributions.BetaPrimeType
      BetaPrime(α, β)

      The Beta prime distribution has probability density function

      \[f(x; \alpha, \beta) = \frac{1}{B(\alpha, \beta)} x^{\alpha - 1} (1 + x)^{- (\alpha + \beta)}, \quad x > 0\]

      The Beta prime distribution is related to the Beta distribution via the relationship that if $X \sim \operatorname{Beta}(\alpha, \beta)$ then $\frac{X}{1 - X} \sim \operatorname{BetaPrime}(\alpha, \beta)$

      BetaPrime()        # equivalent to BetaPrime(1, 1)
       BetaPrime(α)       # equivalent to BetaPrime(α, α)
       BetaPrime(α, β)    # Beta prime distribution with shape parameters α and β
       
      -params(d)          # Get the parameters, i.e. (α, β)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.5 - + 1.0 - + 1.5 - + 2.0 - + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + BetaPrime(1, 2) - + x - + density - + -'/>
      Distributions.CauchyType
      Cauchy(μ, σ)

      The Cauchy distribution with location μ and scale σ has probability density function

      \[f(x; \mu, \sigma) = \frac{1}{\pi \sigma \left(1 + \left(\frac{x - \mu}{\sigma} \right)^2 \right)}\]

      Cauchy()         # Standard Cauchy distribution, i.e. Cauchy(0, 1)
       Cauchy(μ)        # Cauchy distribution with location μ and unit scale, i.e. Cauchy(μ, 1)
      @@ -702,1455 +702,1455 @@
       
       params(d)        # Get the parameters, i.e. (μ, σ)
       location(d)      # Get the location parameter, i.e. μ
      -scale(d)         # Get the scale parameter, i.e. σ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.05 - + 0.10 - + 0.15 - + 0.20 - + 0.25 - + 0.30 - + - - + 10 - + - - + 5 - + 0 - + 5 - + Cauchy(-2, 1) - + x - + density - + -'/>
      Distributions.ChernoffType
      Chernoff()

      The Chernoff distribution is the distribution of the random variable

      \[\underset{t \in (-\infty,\infty)}{\arg\max} ( G(t) - t^2 ),\]

      where $G$ is standard two-sided Brownian motion.

      The distribution arises as the limit distribution of various cube-root-n consistent estimators, including the isotonic regression estimator of Brunk, the isotonic density estimator of Grenander, the least median of squares estimator of Rousseeuw, and the maximum score estimator of Manski.

      For theoretical results, see e.g. Kim and Pollard, Annals of Statistics, 1990. The code for the computation of pdf and cdf is based on the algorithm described in Groeneboom and Wellner, Journal of Computational and Graphical Statistics, 2001.

      cdf(Chernoff(),-x)              # For tail probabilities, use this instead of 1-cdf(Chernoff(),x)
      source
      Distributions.ChernoffType
      Chernoff()

      The Chernoff distribution is the distribution of the random variable

      \[\underset{t \in (-\infty,\infty)}{\arg\max} ( G(t) - t^2 ),\]

      where $G$ is standard two-sided Brownian motion.

      The distribution arises as the limit distribution of various cube-root-n consistent estimators, including the isotonic regression estimator of Brunk, the isotonic density estimator of Grenander, the least median of squares estimator of Rousseeuw, and the maximum score estimator of Manski.

      For theoretical results, see e.g. Kim and Pollard, Annals of Statistics, 1990. The code for the computation of pdf and cdf is based on the algorithm described in Groeneboom and Wellner, Journal of Computational and Graphical Statistics, 2001.

      cdf(Chernoff(),-x)              # For tail probabilities, use this instead of 1-cdf(Chernoff(),x)
      source
      Distributions.ChiType
      Chi(ν)

      The Chi distribution ν degrees of freedom has probability density function

      \[f(x; \nu) = \frac{1}{\Gamma(\nu/2)} 2^{1 - \nu/2} x^{\nu-1} e^{-x^2/2}, \quad x > 0\]

      It is the distribution of the square-root of a Chisq variate.

      Chi(ν)       # Chi distribution with ν degrees of freedom
       
       params(d)    # Get the parameters, i.e. (ν,)
      -dof(d)       # Get the degrees of freedom, i.e. ν

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 0 - + 0.5 - + 1.0 - + 1.5 - + 2.0 - + 2.5 - + 3.0 - + Chi(1) - + x - + density - + '/>
      Distributions.ChisqType
      Chisq(ν)

      The Chi squared distribution (typically written χ²) with ν degrees of freedom has the probability density function

      \[f(x; \nu) = \frac{x^{\nu/2 - 1} e^{-x/2}}{2^{\nu/2} \Gamma(\nu/2)}, \quad x > 0.\]

      If ν is an integer, then it is the distribution of the sum of squares of ν independent standard Normal variates.

      Chisq(ν)     # Chi-squared distribution with ν degrees of freedom
       
       params(d)    # Get the parameters, i.e. (ν,)
      -dof(d)       # Get the degrees of freedom, i.e. ν

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.05 - + 0.10 - + 0.15 - + 0.20 - + 0.25 - + 0 - + 2 - + 4 - + 6 - + 8 - + Chisq(3) - + x - + density - + -'/>
      Distributions.ErlangType
      Erlang(α,θ)

      The Erlang distribution is a special case of a Gamma distribution with integer shape parameter.

      Erlang()       # Erlang distribution with unit shape and unit scale, i.e. Erlang(1, 1)
       Erlang(a)      # Erlang distribution with shape parameter a and unit scale, i.e. Erlang(a, 1)
      -Erlang(a, s)   # Erlang distribution with shape parameter a and scale s

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0 - + 2 - + 4 - + 6 - + 8 - + Erlang(7, 0.5) - + x - + density - + '/>
      Distributions.ExponentialType
      Exponential(θ)

      The Exponential distribution with scale parameter θ has probability density function

      \[f(x; \theta) = \frac{1}{\theta} e^{-\frac{x}{\theta}}, \quad x > 0\]

      Exponential()      # Exponential distribution with unit scale, i.e. Exponential(1)
       Exponential(θ)     # Exponential distribution with scale θ
       
       params(d)          # Get the parameters, i.e. (θ,)
       scale(d)           # Get the scale parameter, i.e. θ
      -rate(d)            # Get the rate parameter, i.e. 1 / θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.5 - + 1.0 - + 1.5 - + 2.0 - + 0 - + 1 - + 2 - + 3 - + 4 - + Exponential(0.5) - + x - + density - + '/>
      Distributions.FDistType
      FDist(ν1, ν2)

      The F distribution has probability density function

      \[f(x; \nu_1, \nu_2) = \frac{1}{x B(\nu_1/2, \nu_2/2)} \sqrt{\frac{(\nu_1 x)^{\nu_1} \cdot \nu_2^{\nu_2}}{(\nu_1 x + \nu_2)^{\nu_1 + \nu_2}}}, \quad x>0\]

      It is related to the Chisq distribution via the property that if $X_1 \sim \operatorname{Chisq}(\nu_1)$ and $X_2 \sim \operatorname{Chisq}(\nu_2)$, then $(X_1/\nu_1) / (X_2 / \nu_2) \sim \operatorname{FDist}(\nu_1, \nu_2)$.

      FDist(ν1, ν2)     # F-Distribution with parameters ν1 and ν2
       
      -params(d)         # Get the parameters, i.e. (ν1, ν2)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0 - + 2 - + 4 - + 6 - + 8 - + 10 - + FDist(10, 1) - + x - + density - + '/>
      Distributions.FrechetType
      Frechet(α,θ)

      The Fréchet distribution with shape α and scale θ has probability density function

      \[f(x; \alpha, \theta) = \frac{\alpha}{\theta} \left( \frac{x}{\theta} \right)^{-\alpha-1} e^{-(x/\theta)^{-\alpha}}, \quad x > 0\]

      Frechet()        # Fréchet distribution with unit shape and unit scale, i.e. Frechet(1, 1)
      @@ -2159,173 +2159,173 @@
       
       params(d)        # Get the parameters, i.e. (α, θ)
       shape(d)         # Get the shape parameter, i.e. α
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0.6 - + 0 - + 5 - + 10 - + 15 - + 20 - + Frechet(1, 1) - + x - + density - + '/>
      Distributions.GammaType
      Gamma(α,θ)

      The Gamma distribution with shape parameter α and scale θ has probability density function

      \[f(x; \alpha, \theta) = \frac{x^{\alpha-1} e^{-x/\theta}}{\Gamma(\alpha) \theta^\alpha}, \quad x > 0\]

      Gamma()          # Gamma distribution with unit shape and unit scale, i.e. Gamma(1, 1)
      @@ -2334,129 +2334,129 @@
       
       params(d)        # Get the parameters, i.e. (α, θ)
       shape(d)         # Get the shape parameter, i.e. α
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.05 - + 0.10 - + 0.15 - + 0 - + 5 - + 10 - + 15 - + Gamma(7.5, 1) - + x - + density - + '/>
      Distributions.GeneralizedExtremeValueType
      GeneralizedExtremeValue(μ, σ, ξ)

      The Generalized extreme value distribution with shape parameter ξ, scale σ and location μ has probability density function

      \[f(x; \xi, \sigma, \mu) = \begin{cases} \frac{1}{\sigma} \left[ 1+\left(\frac{x-\mu}{\sigma}\right)\xi\right]^{-1/\xi-1} \exp\left\{-\left[ 1+ \left(\frac{x-\mu}{\sigma}\right)\xi\right]^{-1/\xi} \right\} & \text{for } \xi \neq 0 \\ @@ -2470,173 +2470,173 @@ params(d) # Get the parameters, i.e. (μ, σ, ξ) location(d) # Get the location parameter, i.e. μ scale(d) # Get the scale parameter, i.e. σ -shape(d) # Get the shape parameter, i.e. ξ (sometimes called c)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0 - + 5 - + 10 - + 15 - + 20 - + 25 - + 30 - + GeneralizedExtremeValue(0, 1, 1) - + x - + density - + '/>
      Distributions.GeneralizedParetoType
      GeneralizedPareto(μ, σ, ξ)

      The Generalized Pareto distribution (GPD) with shape parameter ξ, scale σ and location μ has probability density function

      \[f(x; \mu, \sigma, \xi) = \begin{cases} \frac{1}{\sigma}(1 + \xi \frac{x - \mu}{\sigma} )^{-\frac{1}{\xi} - 1} & \text{for } \xi \neq 0 \\ @@ -2653,160 +2653,160 @@ params(d) # Get the parameters, i.e. (μ, σ, ξ) location(d) # Get the location parameter, i.e. μ scale(d) # Get the scale parameter, i.e. σ -shape(d) # Get the shape parameter, i.e. ξ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 0 - + 5 - + 10 - + 15 - + 20 - + GeneralizedPareto(0, 1, 1) - + x - + density - + '/>
      Distributions.GumbelType
      Gumbel(μ, θ)

      The Gumbel (maxima) distribution with location μ and scale θ has probability density function

      \[f(x; \mu, \theta) = \frac{1}{\theta} e^{-(z + e^{-z})}, \quad \text{ with } z = \frac{x - \mu}{\theta}\]

      Gumbel()            # Gumbel distribution with zero location and unit scale, i.e. Gumbel(0, 1)
      @@ -2815,192 +2815,192 @@
       
       params(d)        # Get the parameters, i.e. (μ, θ)
       location(d)      # Get the location parameter, i.e. μ
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + - - + 2 - + - - + 1 - + 0 - + 1 - + 2 - + 3 - + 4 - + 5 - + Gumbel(0, 1) - + x - + density - + '/>
      Distributions.InverseGammaType
      InverseGamma(α, θ)

      The inverse Gamma distribution with shape parameter α and scale θ has probability density function

      \[f(x; \alpha, \theta) = \frac{\theta^\alpha x^{-(\alpha + 1)}}{\Gamma(\alpha)} e^{-\frac{\theta}{x}}, \quad x > 0\]

      It is related to the Gamma distribution: if $X \sim \operatorname{Gamma}(\alpha, \beta)$, then $1 / X \sim \operatorname{InverseGamma}(\alpha, \beta^{-1})$.

      InverseGamma()        # Inverse Gamma distribution with unit shape and unit scale, i.e. InverseGamma(1, 1)
      @@ -3009,173 +3009,173 @@
       
       params(d)        # Get the parameters, i.e. (α, θ)
       shape(d)         # Get the shape parameter, i.e. α
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 1 - + 2 - + 3 - + 4 - + 5 - + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + InverseGamma(3, 0.5) - + x - + density - + '/>
      Distributions.InverseGaussianType
      InverseGaussian(μ,λ)

      The inverse Gaussian distribution with mean μ and shape λ has probability density function

      \[f(x; \mu, \lambda) = \sqrt{\frac{\lambda}{2\pi x^3}} \exp\!\left(\frac{-\lambda(x-\mu)^2}{2\mu^2x}\right), \quad x > 0\]

      InverseGaussian()              # Inverse Gaussian distribution with unit mean and unit shape, i.e. InverseGaussian(1, 1)
      @@ -3184,620 +3184,620 @@
       
       params(d)           # Get the parameters, i.e. (μ, λ)
       mean(d)             # Get the mean parameter, i.e. μ
      -shape(d)            # Get the shape parameter, i.e. λ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 0 - + 1 - + 2 - + 3 - + 4 - + 5 - + InverseGaussian(1, 1) - + x - + density - + '/>
      Distributions.JohnsonSUType
      JohnsonSU(ξ, λ, γ, δ)

      The Johnson's $S_U$-distribution with parameters ξ, λ, γ and δ is a transformation of the normal distribution:

      If

      \[X = \lambda\sinh\Bigg( \frac{Z - \gamma}{\delta} \Bigg) + \xi\]

      where $Z \sim \mathcal{N}(0,1)$, then $X \sim \operatorname{Johnson}(\xi, \lambda, \gamma, \delta)$.

      JohnsonSU()           # Equivalent to JohnsonSU(0, 1, 0, 1)
       JohnsonSU(ξ, λ, γ, δ) # JohnsonSU's S_U-distribution with parameters ξ, λ, γ and δ
       
       params(d)           # Get the parameters, i.e. (ξ, λ, γ, δ)
       shape(d)            # Get the shape parameter, i.e. ξ
      -scale(d)            # Get the scale parameter, i.e. λ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + - - + 20 - + - - + 10 - + 0 - + 10 - + 20 - + JohnsonSU(0.0, 1.0, 0.0, 1.0) - + x - + density - + -'/>
      Distributions.KolmogorovType
      Kolmogorov()

      Kolmogorov distribution defined as

      \[\sup_{t \in [0,1]} |B(t)|\]

      where $B(t)$ is a Brownian bridge used in the Kolmogorov–Smirnov test for large n.

      source
      Distributions.KolmogorovType
      Kolmogorov()

      Kolmogorov distribution defined as

      \[\sup_{t \in [0,1]} |B(t)|\]

      where $B(t)$ is a Brownian bridge used in the Kolmogorov–Smirnov test for large n.

      source
      Distributions.KSDistType
      KSDist(n)

      Distribution of the (two-sided) Kolmogorov-Smirnoff statistic

      \[D_n = \sup_x | \hat{F}_n(x) -F(x)|\]

      $D_n$ converges a.s. to the Kolmogorov distribution.

      source
      Distributions.KSOneSidedType
      KSOneSided(n)

      Distribution of the one-sided Kolmogorov-Smirnov test statistic:

      \[D^+_n = \sup_x (\hat{F}_n(x) -F(x))\]

      source
      Distributions.KumaraswamyType
      Kumaraswamy(a, b)

      The Kumaraswamy distribution with shape parameters a > 0 and b > 0 has probability density function

      \[f(x; a, b) = a b x^{a - 1} (1 - x^a)^{b - 1}, \quad 0 < x < 1\]

      It is related to the Beta distribution by the following identity: if $X \sim \operatorname{Kumaraswamy}(a, b)$ then $X^a \sim \operatorname{Beta}(1, b)$. In particular, if $X \sim \operatorname{Kumaraswamy}(1, 1)$ then $X \sim \operatorname{Uniform}(0, 1)$.

      External links

      References

      • Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology. 46(1-2), 79-88.
      source
      Distributions.KSDistType
      KSDist(n)

      Distribution of the (two-sided) Kolmogorov-Smirnoff statistic

      \[D_n = \sup_x | \hat{F}_n(x) -F(x)|\]

      $D_n$ converges a.s. to the Kolmogorov distribution.

      source
      Distributions.KSOneSidedType
      KSOneSided(n)

      Distribution of the one-sided Kolmogorov-Smirnov test statistic:

      \[D^+_n = \sup_x (\hat{F}_n(x) -F(x))\]

      source
      Distributions.KumaraswamyType
      Kumaraswamy(a, b)

      The Kumaraswamy distribution with shape parameters a > 0 and b > 0 has probability density function

      \[f(x; a, b) = a b x^{a - 1} (1 - x^a)^{b - 1}, \quad 0 < x < 1\]

      It is related to the Beta distribution by the following identity: if $X \sim \operatorname{Kumaraswamy}(a, b)$ then $X^a \sim \operatorname{Beta}(1, b)$. In particular, if $X \sim \operatorname{Kumaraswamy}(1, 1)$ then $X \sim \operatorname{Uniform}(0, 1)$.

      External links

      References

      • Kumaraswamy, P. (1980). A generalized probability density function for double-bounded random processes. Journal of Hydrology. 46(1-2), 79-88.
      source
      Distributions.LaplaceType
      Laplace(μ,θ)

      The Laplace distribution with location μ and scale θ has probability density function

      \[f(x; \mu, \theta) = \frac{1}{2 \theta} \exp \left(- \frac{|x - \mu|}{\theta} \right)\]

      Laplace()       # Laplace distribution with zero location and unit scale, i.e. Laplace(0, 1)
       Laplace(μ)      # Laplace distribution with location μ and unit scale, i.e. Laplace(μ, 1)
      @@ -3805,183 +3805,183 @@
       
       params(d)       # Get the parameters, i.e., (μ, θ)
       location(d)     # Get the location parameter, i.e. μ
      -scale(d)        # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.02 - + 0.04 - + 0.06 - + 0.08 - + 0.10 - + 0.12 - + - - + 20 - + - - + 10 - + 0 - + 10 - + 20 - + Laplace(0, 4) - + x - + density - + '/>
      Distributions.LevyType
      Levy(μ, σ)

      The Lévy distribution with location μ and scale σ has probability density function

      \[f(x; \mu, \sigma) = \sqrt{\frac{\sigma}{2 \pi (x - \mu)^3}} \exp \left( - \frac{\sigma}{2 (x - \mu)} \right), \quad x > \mu\]

      Levy()         # Levy distribution with zero location and unit scale, i.e. Levy(0, 1)
      @@ -3989,306 +3989,306 @@
       Levy(μ, σ)     # Levy distribution with location μ and scale σ
       
       params(d)      # Get the parameters, i.e. (μ, σ)
      -location(d)    # Get the location parameter, i.e. μ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0 - + 5 - + 10 - + 15 - + 20 - + Levy(0, 1) - + x - + density - + -'/>
      Distributions.LindleyType
      Lindley(θ)

      The one-parameter Lindley distribution with shape θ > 0 has probability density function

      \[f(x; \theta) = \frac{\theta^2}{1 + \theta} (1 + x) e^{-\theta x}, \quad x > 0\]

      It was first described by Lindley[1] and was studied in greater detail by Ghitany et al.[2] Note that Lindley(θ) is a mixture of an Exponential(θ) and a Gamma(2, θ) with respective mixing weights p = θ/(1 + θ) and 1 - p.

      source
      Distributions.LindleyType
      Lindley(θ)

      The one-parameter Lindley distribution with shape θ > 0 has probability density function

      \[f(x; \theta) = \frac{\theta^2}{1 + \theta} (1 + x) e^{-\theta x}, \quad x > 0\]

      It was first described by Lindley[1] and was studied in greater detail by Ghitany et al.[2] Note that Lindley(θ) is a mixture of an Exponential(θ) and a Gamma(2, θ) with respective mixing weights p = θ/(1 + θ) and 1 - p.

      source
      Distributions.LogisticType
      Logistic(μ,θ)

      The Logistic distribution with location μ and scale θ has probability density function

      \[f(x; \mu, \theta) = \frac{1}{4 \theta} \mathrm{sech}^2 \left( \frac{x - \mu}{2 \theta} \right)\]

      Logistic()       # Logistic distribution with zero location and unit scale, i.e. Logistic(0, 1)
      @@ -4297,192 +4297,192 @@
       
       params(d)       # Get the parameters, i.e. (μ, θ)
       location(d)     # Get the location parameter, i.e. μ
      -scale(d)        # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.05 - + 0.10 - + 0.15 - + 0.20 - + 0.25 - + - - + 4 - + - - + 2 - + 0 - + 2 - + 4 - + 6 - + 8 - + Logistic(2, 1) - + x - + density - + '/>
      Distributions.LogitNormalType
      LogitNormal(μ,σ)

      The logit normal distribution is the distribution of of a random variable whose logit has a Normal distribution. Or inversely, when applying the logistic function to a Normal random variable then the resulting random variable follows a logit normal distribution.

      If $X \sim \operatorname{Normal}(\mu, \sigma)$ then $\operatorname{logistic}(X) \sim \operatorname{LogitNormal}(\mu,\sigma)$.

      The probability density function is

      \[f(x; \mu, \sigma) = \frac{1}{x \sqrt{2 \pi \sigma^2}} \exp \left( - \frac{(\text{logit}(x) - \mu)^2}{2 \sigma^2} \right), @@ -4495,149 +4495,149 @@ median(d) # Get the median, i.e. logistic(μ)

      The following properties have no analytical solution but numerical approximations. In order to avoid package dependencies for numerical optimization, they are currently not implemented.

      mean(d)
       var(d)
       std(d)
      -mode(d)

      Similarly, skewness, kurtosis, and entropy are not implemented.

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.5 - + 1.0 - + 1.5 - + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + LogitNormal(0, 1) - + x - + density - + '/>
      Distributions.LogNormalType
      LogNormal(μ,σ)

      The log normal distribution is the distribution of the exponential of a Normal variate: if $X \sim \operatorname{Normal}(\mu, \sigma)$ then $\exp(X) \sim \operatorname{LogNormal}(\mu,\sigma)$. The probability density function is

      \[f(x; \mu, \sigma) = \frac{1}{x \sqrt{2 \pi \sigma^2}} \exp \left( - \frac{(\log(x) - \mu)^2}{2 \sigma^2} \right), @@ -4648,1044 +4648,1044 @@ params(d) # Get the parameters, i.e. (μ, σ) meanlogx(d) # Get the mean of log(X), i.e. μ varlogx(d) # Get the variance of log(X), i.e. σ^2 -stdlogx(d) # Get the standard deviation of log(X), i.e. σ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0.6 - + 0.7 - + 0 - + 1 - + 2 - + 3 - + 4 - + 5 - + LogNormal(0, 1) - + x - + density - + -'/>
      Distributions.NoncentralBetaType
      NoncentralBeta(α, β, λ)

      Noncentral Beta distribution with shape parameters α > 0 and β > 0 and noncentrality parameter λ >= 0.

      source
      Distributions.NoncentralBetaType
      NoncentralBeta(α, β, λ)

      Noncentral Beta distribution with shape parameters α > 0 and β > 0 and noncentrality parameter λ >= 0.

      source
      Distributions.NoncentralChisqType
      NoncentralChisq(ν, λ)

      The noncentral chi-squared distribution with ν degrees of freedom and noncentrality parameter λ has the probability density function

      \[f(x; \nu, \lambda) = \frac{1}{2} e^{-(x + \lambda)/2} \left( \frac{x}{\lambda} \right)^{\nu/4-1/2} I_{\nu/2-1}(\sqrt{\lambda x}), \quad x > 0\]

      It is the distribution of the sum of squares of ν independent Normal variates with individual means $\mu_i$ and

      \[\lambda = \sum_{i=1}^\nu \mu_i^2\]

      NoncentralChisq(ν, λ)     # Noncentral chi-squared distribution with ν degrees of freedom and noncentrality parameter λ
       
      -params(d)    # Get the parameters, i.e. (ν, λ)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.02 - + 0.04 - + 0.06 - + 0.08 - + 0.10 - + 0.12 - + 0.14 - + 0 - + 5 - + 10 - + 15 - + 20 - + NoncentralChisq(2, 3) - + x - + density - + -'/>
      Distributions.NoncentralFType
      NoncentralF(ν1, ν2, λ)

      Noncentral F-distribution with ν1 > 0 and ν2 > 0 degrees of freedom and noncentrality parameter λ >= 0.

      source
      Distributions.NoncentralFType
      NoncentralF(ν1, ν2, λ)

      Noncentral F-distribution with ν1 > 0 and ν2 > 0 degrees of freedom and noncentrality parameter λ >= 0.

      source
      Distributions.NoncentralTType
      NoncentralT(ν, λ)

      Noncentral Student's t-distribution with v > 0 degrees of freedom and noncentrality parameter λ.

      source
      Distributions.NoncentralTType
      NoncentralT(ν, λ)

      Noncentral Student's t-distribution with v > 0 degrees of freedom and noncentrality parameter λ.

      source
      Distributions.NormalType
      Normal(μ,σ)

      The Normal distribution with mean μ and standard deviation σ≥0 has probability density function

      \[f(x; \mu, \sigma) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp \left( - \frac{(x - \mu)^2}{2 \sigma^2} \right)\]

      Note that if σ == 0, then the distribution is a point mass concentrated at μ. Though not technically a continuous distribution, it is allowed so as to account for cases where σ may have underflowed, and the functions are defined by taking the pointwise limit as $σ → 0$.

      Normal()          # standard Normal distribution with zero mean and unit variance
      @@ -5694,449 +5694,449 @@
       
       params(d)         # Get the parameters, i.e. (μ, σ)
       mean(d)           # Get the mean, i.e. μ
      -std(d)            # Get the standard deviation, i.e. σ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + - - + 4 - + - - + 2 - + 0 - + 2 - + 4 - + Normal(0, 1) - + x - + density - + -'/>
      Distributions.NormalCanonType
      NormalCanon(η, λ)

      Canonical parametrisation of the Normal distribution with canonical parameters η and λ.

      The two canonical parameters of a normal distribution $\mathcal{N}(\mu, \sigma^2)$ with mean $\mu$ and standard deviation $\sigma$ are $\eta = \sigma^{-2} \mu$ and $\lambda = \sigma^{-2}$.

      source
      Distributions.NormalCanonType
      NormalCanon(η, λ)

      Canonical parametrisation of the Normal distribution with canonical parameters η and λ.

      The two canonical parameters of a normal distribution $\mathcal{N}(\mu, \sigma^2)$ with mean $\mu$ and standard deviation $\sigma$ are $\eta = \sigma^{-2} \mu$ and $\lambda = \sigma^{-2}$.

      source
      Distributions.NormalInverseGaussianType
      NormalInverseGaussian(μ,α,β,δ)

      The Normal-inverse Gaussian distribution with location μ, tail heaviness α, asymmetry parameter β and scale δ has probability density function

      \[f(x; \mu, \alpha, \beta, \delta) = \frac{\alpha\delta K_1 \left(\alpha\sqrt{\delta^2 + (x - \mu)^2}\right)}{\pi \sqrt{\delta^2 + (x - \mu)^2}} \; e^{\delta \gamma + \beta (x - \mu)}\]

      where $K_j$ denotes a modified Bessel function of the third kind.

      External links

      source
      Distributions.NormalInverseGaussianType
      NormalInverseGaussian(μ,α,β,δ)

      The Normal-inverse Gaussian distribution with location μ, tail heaviness α, asymmetry parameter β and scale δ has probability density function

      \[f(x; \mu, \alpha, \beta, \delta) = \frac{\alpha\delta K_1 \left(\alpha\sqrt{\delta^2 + (x - \mu)^2}\right)}{\pi \sqrt{\delta^2 + (x - \mu)^2}} \; e^{\delta \gamma + \beta (x - \mu)}\]

      where $K_j$ denotes a modified Bessel function of the third kind.

      External links

      source
      Distributions.ParetoType
      Pareto(α,θ)

      The Pareto distribution with shape α and scale θ has probability density function

      \[f(x; \alpha, \theta) = \frac{\alpha \theta^\alpha}{x^{\alpha + 1}}, \quad x \ge \theta\]

      Pareto()            # Pareto distribution with unit shape and unit scale, i.e. Pareto(1, 1)
       Pareto(α)           # Pareto distribution with shape α and unit scale, i.e. Pareto(α, 1)
      @@ -6144,199 +6144,199 @@
       
       params(d)        # Get the parameters, i.e. (α, θ)
       shape(d)         # Get the shape parameter, i.e. α
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 1 - + 2 - + 3 - + 4 - + 5 - + 6 - + 7 - + 8 - + Pareto(1, 1) - + x - + density - + '/>
      Distributions.PGeneralizedGaussianType
      PGeneralizedGaussian(μ, α, p)

      The p-Generalized Gaussian distribution, more commonly known as the exponential power or the generalized normal distribution, with scale α, location μ, and shape p has the probability density function

      \[f(x, \mu, \alpha, p) = \frac{p}{2\alpha\Gamma(1/p)} e^{-(\frac{|x-\mu|}{\alpha})^p} \quad x \in (-\infty, +\infty) , \alpha > 0, p > 0\]

      The p-Generalized Gaussian (GGD) is a parametric distribution that incorporates the normal (p = 2) and Laplacian (p = 1) distributions as special cases. As p → ∞, the distribution approaches the Uniform distribution on [μ - α, μ + α].

      PGeneralizedGaussian()           # GGD with location 0, scale √2, and shape 2 (the normal distribution)
       PGeneralizedGaussian(μ, α, p)    # GGD with location μ, scale α, and shape p
      @@ -6344,711 +6344,711 @@
       params(d)                        # Get the parameters, i.e. (μ, α, p)
       location(d)                      # Get the location parameter, μ
       scale(d)                         # Get the scale parameter, α
      -shape(d)                         # Get the shape parameter, p

      External Links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.001 - + 0.002 - + 0.003 - + 0.004 - + 0.005 - + 0 - + 5 - + 10 - + 15 - + 20 - + PGeneralizedGaussian(0.2) - + x - + density - + '/>
      Distributions.RayleighType
      Rayleigh(σ)

      The Rayleigh distribution with scale σ has probability density function

      \[f(x; \sigma) = \frac{x}{\sigma^2} e^{-\frac{x^2}{2 \sigma^2}}, \quad x > 0\]

      It is related to the Normal distribution via the property that if $X, Y \sim \operatorname{Normal}(0,\sigma)$, independently, then $\sqrt{X^2 + Y^2} \sim \operatorname{Rayleigh}(\sigma)$.

      Rayleigh()       # Rayleigh distribution with unit scale, i.e. Rayleigh(1)
       Rayleigh(σ)      # Rayleigh distribution with scale σ
       
       params(d)        # Get the parameters, i.e. (σ,)
      -scale(d)         # Get the scale parameter, i.e. σ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 1.2 - + 0 - + 0.5 - + 1.0 - + 1.5 - + 2.0 - + Rayleigh(0.5) - + x - + density - + '/>
      Distributions.RicianType
      Rician(ν, σ)

      The Rician distribution with parameters ν and σ has probability density function:

      \[f(x; \nu, \sigma) = \frac{x}{\sigma^2} \exp\left( \frac{-(x^2 + \nu^2)}{2\sigma^2} \right) I_0\left( \frac{x\nu}{\sigma^2} \right).\]

      If shape and scale parameters K and Ω are given instead, ν and σ may be computed from them:

      \[\sigma = \sqrt{\frac{\Omega}{2(K + 1)}}, \quad \nu = \sigma\sqrt{2K}\]

      Rician()         # Rician distribution with parameters ν=0 and σ=1
       Rician(ν, σ)     # Rician distribution with parameters ν and σ
       
       params(d)        # Get the parameters, i.e. (ν, σ)
       shape(d)         # Get the shape parameter K = ν²/2σ²
      -scale(d)         # Get the scale parameter Ω = ν² + 2σ²

      External links:

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0.6 - + 0 - + 1 - + 2 - + 3 - + 4 - + 5 - + Rician(0.5, 1) - + x - + density - + '/>
      Distributions.SemicircleType
      Semicircle(r)

      The Wigner semicircle distribution with radius parameter r has probability density function

      \[f(x; r) = \frac{2}{\pi r^2} \sqrt{r^2 - x^2}, \quad x \in [-r, r].\]

      Semicircle(r)   # Wigner semicircle distribution with radius r
       
      -params(d)       # Get the radius parameter, i.e. (r,)

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0.6 - + 0.7 - + - - + 1.0 - + - - + 0.5 - + 0 - + 0.5 - + 1.0 - + Semicircle(1) - + x - + density - + '/>
      Distributions.SkewedExponentialPowerType
      SkewedExponentialPower(μ, σ, p, α)

      The Skewed exponential power distribution, with location μ, scale σ, shape p, and skewness α, has the probability density function [1]

      \[f(x; \mu, \sigma, p, \alpha) = \begin{cases} @@ -7063,724 +7063,724 @@ params(d) # Get the parameters, i.e. (μ, σ, p, α) shape(d) # Get the shape parameter, i.e. p location(d) # Get the location parameter, i.e. μ -scale(d) # Get the scale parameter, i.e. σ

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + 0.6 - + 0.7 - + - - + 8 - + - - + 6 - + - - + 4 - + - - + 2 - + 0 - + 2 - + 4 - + SkewedExponentialPower(0, 1, 0.7, 0.7) - + x - + density - + '/>
      Distributions.SkewNormalType
      SkewNormal(ξ, ω, α)

      The skew normal distribution is a continuous probability distribution that generalises the normal distribution to allow for non-zero skewness. Given a location ξ, scale ω, and shape α, it has the probability density function

      \[f(x; \xi, \omega, \alpha) = \frac{2}{\omega \sqrt{2 \pi}} \exp{\bigg(-\frac{(x-\xi)^2}{2\omega^2}\bigg)} \int_{-\infty}^{\alpha\left(\frac{x-\xi}{\omega}\right)} -\frac{1}{\sqrt{2 \pi}} \exp{\bigg(-\frac{t^2}{2}\bigg)} \, \mathrm{d}t\]

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + 0.5 - + - - + 4 - + - - + 2 - + 0 - + 2 - + 4 - + SkewNormal(0, 1, -1) - + x - + density - + '/>
      Distributions.StudentizedRangeType
      StudentizedRange(ν, k)

      The studentized range distribution has probability density function:

      \[f(q; k, \nu) = \frac{\sqrt{2\pi}k(k - 1)\nu^{\nu/2}}{\Gamma{\left(\frac{\nu}{2}\right)}2^{\nu/2 - 1}} \int_{0}^{\infty} {x^{\nu}\phi(\sqrt{\nu}x)} \left[\int_{-\infty}^{\infty} {\phi(u)\phi(u - qx)[\Phi(u) - \Phi(u - qx)]^{k - 2}}du\right]dx\]

      where

      \[\begin{aligned} \Phi(x) &= \frac{1 + erf(\frac{x}{\sqrt{2}})}{2} &&(\text{Normal Distribution CDF})\\ \phi(x) &= \Phi'(x) &&(\text{Normal Distribution PDF}) \end{aligned}\]

      StudentizedRange(ν, k)     # Studentized Range Distribution with parameters ν and k
       
      -params(d)        # Get the parameters, i.e. (ν, k)

      External links

      source
      Distributions.SymTriangularDistType
      SymTriangularDist(μ, σ)

      The Symmetric triangular distribution with location μ and scale σ has probability density function

      \[f(x; \mu, \sigma) = \frac{1}{\sigma} \left( 1 - \left| \frac{x - \mu}{\sigma} \right| \right), \quad \mu - \sigma \le x \le \mu + \sigma\]

      SymTriangularDist()         # Symmetric triangular distribution with zero location and unit scale
      +params(d)        # Get the parameters, i.e. (ν, k)

      External links

      source
      Distributions.SymTriangularDistType
      SymTriangularDist(μ, σ)

      The Symmetric triangular distribution with location μ and scale σ has probability density function

      \[f(x; \mu, \sigma) = \frac{1}{\sigma} \left( 1 - \left| \frac{x - \mu}{\sigma} \right| \right), \quad \mu - \sigma \le x \le \mu + \sigma\]

      SymTriangularDist()         # Symmetric triangular distribution with zero location and unit scale
       SymTriangularDist(μ)        # Symmetric triangular distribution with location μ and unit scale
       SymTriangularDist(μ, s)     # Symmetric triangular distribution with location μ and scale σ
       
       params(d)       # Get the parameters, i.e. (μ, σ)
       location(d)     # Get the location parameter, i.e. μ
      -scale(d)        # Get the scale parameter, i.e. σ
      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + - - + 2 - + - - + 1 - + 0 - + 1 - + 2 - + SymTriangularDist(0, 1) - + x - + density - + '/>
      Distributions.TDistType
      TDist(ν)

      The Students T distribution with ν degrees of freedom has probability density function

      \[f(x; \nu) = \frac{1}{\sqrt{\nu} B(1/2, \nu/2)} \left( 1 + \frac{x^2}{\nu} \right)^{-\frac{\nu + 1}{2}}\]

      TDist(d)      # t-distribution with ν degrees of freedom
       
       params(d)     # Get the parameters, i.e. (ν,)
      -dof(d)        # Get the degrees of freedom, i.e. ν

      External links

      Student's T distribution on Wikipedia

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.1 - + 0.2 - + 0.3 - + 0.4 - + - - + 4 - + - - + 2 - + 0 - + 2 - + 4 - + TDist(5) - + x - + density - + '/>
      Distributions.TriangularDistType
      TriangularDist(a,b,c)

      The triangular distribution with lower limit a, upper limit b and mode c has probability density function

      \[f(x; a, b, c)= \begin{cases} 0 & \mathrm{for\ } x < a, \\ @@ -7793,361 +7793,361 @@ params(d) # Get the parameters, i.e. (a, b, c) minimum(d) # Get the lower bound, i.e. a maximum(d) # Get the upper bound, i.e. b -mode(d) # Get the mode, i.e. c

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 1.2 - + 1.4 - + - - + 0.5 - + 0 - + 0.5 - + 1.0 - + 1.5 - + 2.0 - + TriangularDist(0, 1.5, 0.5) - + x - + density - + -'/>
      Distributions.UniformType
      Uniform(a,b)

      The continuous uniform distribution over an interval $[a, b]$ has probability density function

      \[f(x; a, b) = \frac{1}{b - a}, \quad a \le x \le b\]

      Uniform()        # Uniform distribution over [0, 1]
       Uniform(a, b)    # Uniform distribution over [a, b]
      @@ -8156,273 +8156,273 @@
       minimum(d)       # Get the lower bound, i.e. a
       maximum(d)       # Get the upper bound, i.e. b
       location(d)      # Get the location parameter, i.e. a
      -scale(d)         # Get the scale parameter, i.e. b - a

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 0.2 - + 0.4 - + 0.6 - + 0.8 - + 1.0 - + 1.2 - + 1.4 - + - - + 0.5 - + 0 - + 0.5 - + 1.0 - + 1.5 - + Uniform(0, 1) - + x - + density - + '/>
      Distributions.VonMisesType
      VonMises(μ, κ)

      The von Mises distribution with mean μ and concentration κ has probability density function

      \[f(x; \mu, \kappa) = \frac{1}{2 \pi I_0(\kappa)} \exp \left( \kappa \cos (x - \mu) \right)\]

      VonMises()       # von Mises distribution with zero mean and unit concentration
       VonMises(κ)      # von Mises distribution with zero mean and concentration κ
      -VonMises(μ, κ)   # von Mises distribution with mean μ and concentration κ

      External links

      source
      - + - + - - - + + + 0.1 - - - - - - + + + + + + 0.15 - - - - - - + + + + + + 0.2 - - - - - - + + + + + + 0.25 - - - + + + - - + π - - - - - - + + + + + + 0 - - - - - - + + + + + + π - - - + + + VonMises(0.5) - + x - + density - + '/>
      Distributions.WeibullType
      Weibull(α,θ)

      The Weibull distribution with shape α and scale θ has probability density function

      \[f(x; \alpha, \theta) = \frac{\alpha}{\theta} \left( \frac{x}{\theta} \right)^{\alpha-1} e^{-(x/\theta)^\alpha}, \quad x \ge 0\]

      Weibull()        # Weibull distribution with unit shape and unit scale, i.e. Weibull(1, 1)
      @@ -8431,162 +8431,162 @@
       
       params(d)        # Get the parameters, i.e. (α, θ)
       shape(d)         # Get the shape parameter, i.e. α
      -scale(d)         # Get the scale parameter, i.e. θ

      External links

      source
      - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 - + 5 - + 10 - + 15 - + 0 - + 0.5 - + 1.0 - + 1.5 - + 2.0 - + 2.5 - + 3.0 - + Weibull(0.5, 1) - + x - + density - + '/>

      Discrete Distributions

      Distributions.BernoulliType
      Bernoulli(p)

      A Bernoulli distribution is parameterized by a success rate p, which takes value 1 with probability p and 0 with probability 1-p.

      \[P(X = k) = \begin{cases} 1 - p & \quad \text{for } k = 0, \\ @@ -8596,60 +8596,60 @@ params(d) # Get the parameters, i.e. (p,) succprob(d) # Get the success rate, i.e. p -failprob(d) # Get the failure rate, i.e. 1 - p

      External links:

      source
      Distributions.BernoulliLogitType
      BernoulliLogit(logitp=0.0)

      A Bernoulli distribution that is parameterized by the logit logitp = logit(p) = log(p/(1-p)) of its success rate p.

      \[P(X = k) = \begin{cases} \operatorname{logistic}(-logitp) = \frac{1}{1 + \exp{(logitp)}} & \quad \text{for } k = 0, \\ \operatorname{logistic}(logitp) = \frac{1}{1 + \exp{(-logitp)}} & \quad \text{for } k = 1. -\end{cases}\]

      External links:

      See also Bernoulli

      source
      Distributions.BetaBinomialType
      BetaBinomial(n,α,β)

      A Beta-binomial distribution is the compound distribution of the Binomial distribution where the probability of success p is distributed according to the Beta. It has three parameters: n, the number of trials and two shape parameters α, β

      \[P(X = k) = {n \choose k} B(k + \alpha, n - k + \beta) / B(\alpha, \beta), \quad \text{ for } k = 0,1,2, \ldots, n.\]

      BetaBinomial(n, α, β)      # BetaBinomial distribution with n trials and shape parameters α, β
      +\end{cases}\]

      External links:

      See also Bernoulli

      source
      Distributions.BetaBinomialType
      BetaBinomial(n,α,β)

      A Beta-binomial distribution is the compound distribution of the Binomial distribution where the probability of success p is distributed according to the Beta. It has three parameters: n, the number of trials and two shape parameters α, β

      \[P(X = k) = {n \choose k} B(k + \alpha, n - k + \beta) / B(\alpha, \beta), \quad \text{ for } k = 0,1,2, \ldots, n.\]

      BetaBinomial(n, α, β)      # BetaBinomial distribution with n trials and shape parameters α, β
       
       params(d)       # Get the parameters, i.e. (n, α, β)
      -ntrials(d)      # Get the number of trials, i.e. n

      External links:

      source
      Distributions.BinomialType
      Binomial(n,p)

      A Binomial distribution characterizes the number of successes in a sequence of independent trials. It has two parameters: n, the number of trials, and p, the probability of success in an individual trial, with the distribution:

      \[P(X = k) = {n \choose k}p^k(1-p)^{n-k}, \quad \text{ for } k = 0,1,2, \ldots, n.\]

      Binomial()      # Binomial distribution with n = 1 and p = 0.5
      +ntrials(d)      # Get the number of trials, i.e. n

      External links:

      source
      Distributions.BinomialType
      Binomial(n,p)

      A Binomial distribution characterizes the number of successes in a sequence of independent trials. It has two parameters: n, the number of trials, and p, the probability of success in an individual trial, with the distribution:

      \[P(X = k) = {n \choose k}p^k(1-p)^{n-k}, \quad \text{ for } k = 0,1,2, \ldots, n.\]

      Binomial()      # Binomial distribution with n = 1 and p = 0.5
       Binomial(n)     # Binomial distribution for n trials with success rate p = 0.5
       Binomial(n, p)  # Binomial distribution for n trials with success rate p
       
       params(d)       # Get the parameters, i.e. (n, p)
       ntrials(d)      # Get the number of trials, i.e. n
       succprob(d)     # Get the success rate, i.e. p
      -failprob(d)     # Get the failure rate, i.e. 1 - p

      External links:

      source
      Distributions.CategoricalType
      Categorical(p)

      A Categorical distribution is parameterized by a probability vector p (of length K).

      \[P(X = k) = p[k] \quad \text{for } k = 1, 2, \ldots, K.\]

      Categorical(p)   # Categorical distribution with probability vector p
      +failprob(d)     # Get the failure rate, i.e. 1 - p

      External links:

      source
      Distributions.CategoricalType
      Categorical(p)

      A Categorical distribution is parameterized by a probability vector p (of length K).

      \[P(X = k) = p[k] \quad \text{for } k = 1, 2, \ldots, K.\]

      Categorical(p)   # Categorical distribution with probability vector p
       params(d)        # Get the parameters, i.e. (p,)
       probs(d)         # Get the probability vector, i.e. p
      -ncategories(d)   # Get the number of categories, i.e. K

      Here, p must be a real vector, of which all components are nonnegative and sum to one.

      Note: The input vector p is directly used as a field of the constructed distribution, without being copied.

      Categorical is simply a type alias describing a special case of a DiscreteNonParametric distribution, so non-specialized methods defined for DiscreteNonParametric apply to Categorical as well.

      External links:

      source
      Distributions.DiracType
      Dirac(x)

      A Dirac distribution is parameterized by its only value x, and takes its value with probability 1.

      \[P(X = \hat{x}) = \begin{cases} +ncategories(d) # Get the number of categories, i.e. K

      Here, p must be a real vector, of which all components are nonnegative and sum to one.

      Note: The input vector p is directly used as a field of the constructed distribution, without being copied.

      Categorical is simply a type alias describing a special case of a DiscreteNonParametric distribution, so non-specialized methods defined for DiscreteNonParametric apply to Categorical as well.

      External links:

      source
      Distributions.DiracType
      Dirac(x)

      A Dirac distribution is parameterized by its only value x, and takes its value with probability 1.

      \[P(X = \hat{x}) = \begin{cases} 1 & \quad \text{for } \hat{x} = x, \\ 0 & \quad \text{for } \hat{x} \neq x. -\end{cases}\]

      Dirac(2.5)   # Dirac distribution with value x = 2.5

      External links:

      source
      Distributions.DiscreteUniformType
      DiscreteUniform(a,b)

      A Discrete uniform distribution is a uniform distribution over a consecutive sequence of integers between a and b, inclusive.

      \[P(X = k) = 1 / (b - a + 1) \quad \text{for } k = a, a+1, \ldots, b.\]

      DiscreteUniform(a, b)   # a uniform distribution over {a, a+1, ..., b}
      +\end{cases}\]

      Dirac(2.5)   # Dirac distribution with value x = 2.5

      External links:

      source
      Distributions.DiscreteUniformType
      DiscreteUniform(a,b)

      A Discrete uniform distribution is a uniform distribution over a consecutive sequence of integers between a and b, inclusive.

      \[P(X = k) = 1 / (b - a + 1) \quad \text{for } k = a, a+1, \ldots, b.\]

      DiscreteUniform(a, b)   # a uniform distribution over {a, a+1, ..., b}
       
       params(d)       # Get the parameters, i.e. (a, b)
       span(d)         # Get the span of the support, i.e. (b - a + 1)
       probval(d)      # Get the probability value, i.e. 1 / (b - a + 1)
       minimum(d)      # Return a
      -maximum(d)      # Return b

      External links

      source
      Distributions.DiscreteNonParametricType
      DiscreteNonParametric(xs, ps)

      A Discrete nonparametric distribution explicitly defines an arbitrary probability mass function in terms of a list of real support values and their corresponding probabilities

      d = DiscreteNonParametric(xs, ps)
       
       params(d)  # Get the parameters, i.e. (xs, ps)
       support(d) # Get a sorted AbstractVector describing the support (xs) of the distribution
      -probs(d)   # Get a Vector of the probabilities (ps) associated with the support

      External links

      source
      Distributions.GeometricType
      Geometric(p)

      A Geometric distribution characterizes the number of failures before the first success in a sequence of independent Bernoulli trials with success rate p.

      \[P(X = k) = p (1 - p)^k, \quad \text{for } k = 0, 1, 2, \ldots.\]

      Geometric()    # Geometric distribution with success rate 0.5
      +probs(d)   # Get a Vector of the probabilities (ps) associated with the support

      External links

      source
      Distributions.GeometricType
      Geometric(p)

      A Geometric distribution characterizes the number of failures before the first success in a sequence of independent Bernoulli trials with success rate p.

      \[P(X = k) = p (1 - p)^k, \quad \text{for } k = 0, 1, 2, \ldots.\]

      Geometric()    # Geometric distribution with success rate 0.5
       Geometric(p)   # Geometric distribution with success rate p
       
       params(d)      # Get the parameters, i.e. (p,)
       succprob(d)    # Get the success rate, i.e. p
      -failprob(d)    # Get the failure rate, i.e. 1 - p

      External links

      source
      Distributions.HypergeometricType
      Hypergeometric(s, f, n)

      A Hypergeometric distribution describes the number of successes in n draws without replacement from a finite population containing s successes and f failures.

      \[P(X = k) = {{{s \choose k} {f \choose {n-k}}}\over {s+f \choose n}}, \quad \text{for } k = \max(0, n - f), \ldots, \min(n, s).\]

      Hypergeometric(s, f, n)  # Hypergeometric distribution for a population with
      +failprob(d)    # Get the failure rate, i.e. 1 - p

      External links

      source
      Distributions.HypergeometricType
      Hypergeometric(s, f, n)

      A Hypergeometric distribution describes the number of successes in n draws without replacement from a finite population containing s successes and f failures.

      \[P(X = k) = {{{s \choose k} {f \choose {n-k}}}\over {s+f \choose n}}, \quad \text{for } k = \max(0, n - f), \ldots, \min(n, s).\]

      Hypergeometric(s, f, n)  # Hypergeometric distribution for a population with
                                # s successes and f failures, and a sequence of n trials.
       
      -params(d)       # Get the parameters, i.e. (s, f, n)

      External links

      source
      Distributions.NegativeBinomialType
      NegativeBinomial(r,p)

      A Negative binomial distribution describes the number of failures before the rth success in a sequence of independent Bernoulli trials. It is parameterized by r, the number of successes, and p, the probability of success in an individual trial.

      \[P(X = k) = {k + r - 1 \choose k} p^r (1 - p)^k, \quad \text{for } k = 0,1,2,\ldots.\]

      The distribution remains well-defined for any positive r, in which case

      \[P(X = k) = \frac{\Gamma(k+r)}{k! \Gamma(r)} p^r (1 - p)^k, \quad \text{for } k = 0,1,2,\ldots.\]

      NegativeBinomial()        # Negative binomial distribution with r = 1 and p = 0.5
      +params(d)       # Get the parameters, i.e. (s, f, n)

      External links

      source
      Distributions.NegativeBinomialType
      NegativeBinomial(r,p)

      A Negative binomial distribution describes the number of failures before the rth success in a sequence of independent Bernoulli trials. It is parameterized by r, the number of successes, and p, the probability of success in an individual trial.

      \[P(X = k) = {k + r - 1 \choose k} p^r (1 - p)^k, \quad \text{for } k = 0,1,2,\ldots.\]

      The distribution remains well-defined for any positive r, in which case

      \[P(X = k) = \frac{\Gamma(k+r)}{k! \Gamma(r)} p^r (1 - p)^k, \quad \text{for } k = 0,1,2,\ldots.\]

      NegativeBinomial()        # Negative binomial distribution with r = 1 and p = 0.5
       NegativeBinomial(r, p)    # Negative binomial distribution with r successes and success rate p
       
       params(d)       # Get the parameters, i.e. (r, p)
       succprob(d)     # Get the success rate, i.e. p
      -failprob(d)     # Get the failure rate, i.e. 1 - p

      External links:

      source
      Distributions.PoissonType
      Poisson(λ)

      A Poisson distribution describes the number of independent events occurring within a unit time interval, given the average rate of occurrence λ.

      \[P(X = k) = \frac{\lambda^k}{k!} e^{-\lambda}, \quad \text{ for } k = 0,1,2,\ldots.\]

      Poisson()        # Poisson distribution with rate parameter 1
      +failprob(d)     # Get the failure rate, i.e. 1 - p

      External links:

      source
      Distributions.PoissonType
      Poisson(λ)

      A Poisson distribution describes the number of independent events occurring within a unit time interval, given the average rate of occurrence λ.

      \[P(X = k) = \frac{\lambda^k}{k!} e^{-\lambda}, \quad \text{ for } k = 0,1,2,\ldots.\]

      Poisson()        # Poisson distribution with rate parameter 1
       Poisson(lambda)       # Poisson distribution with rate parameter lambda
       
       params(d)        # Get the parameters, i.e. (λ,)
      -mean(d)          # Get the mean arrival rate, i.e. λ

      External links:

      source
      Distributions.PoissonBinomialType
      PoissonBinomial(p)

      A Poisson-binomial distribution describes the number of successes in a sequence of independent trials, wherein each trial has a different success rate. It is parameterized by a vector p (of length $K$), where $K$ is the total number of trials and p[i] corresponds to the probability of success of the ith trial.

      \[P(X = k) = \sum\limits_{A\in F_k} \prod\limits_{i\in A} p[i] \prod\limits_{j\in A^c} (1-p[j]), \quad \text{ for } k = 0,1,2,\ldots,K,\]

      where $F_k$ is the set of all subsets of $k$ integers that can be selected from $\{1,2,3,...,K\}$.

      PoissonBinomial(p)   # Poisson Binomial distribution with success rate vector p
      +mean(d)          # Get the mean arrival rate, i.e. λ

      External links:

      source
      Distributions.PoissonBinomialType
      PoissonBinomial(p)

      A Poisson-binomial distribution describes the number of successes in a sequence of independent trials, wherein each trial has a different success rate. It is parameterized by a vector p (of length $K$), where $K$ is the total number of trials and p[i] corresponds to the probability of success of the ith trial.

      \[P(X = k) = \sum\limits_{A\in F_k} \prod\limits_{i\in A} p[i] \prod\limits_{j\in A^c} (1-p[j]), \quad \text{ for } k = 0,1,2,\ldots,K,\]

      where $F_k$ is the set of all subsets of $k$ integers that can be selected from $\{1,2,3,...,K\}$.

      PoissonBinomial(p)   # Poisson Binomial distribution with success rate vector p
       
       params(d)            # Get the parameters, i.e. (p,)
       succprob(d)          # Get the vector of success rates, i.e. p
      -failprob(d)          # Get the vector of failure rates, i.e. 1-p

      External links:

      source
      Distributions.SkellamType
      Skellam(μ1, μ2)

      A Skellam distribution describes the difference between two independent Poisson variables, respectively with rate μ1 and μ2.

      \[P(X = k) = e^{-(\mu_1 + \mu_2)} \left( \frac{\mu_1}{\mu_2} \right)^{k/2} I_k(2 \sqrt{\mu_1 \mu_2}) \quad \text{for integer } k\]

      where $I_k$ is the modified Bessel function of the first kind.

      Skellam(μ1, μ2)     # Skellam distribution for the difference between two Poisson variables,
      +failprob(d)          # Get the vector of failure rates, i.e. 1-p

      External links:

      source
      Distributions.SkellamType
      Skellam(μ1, μ2)

      A Skellam distribution describes the difference between two independent Poisson variables, respectively with rate μ1 and μ2.

      \[P(X = k) = e^{-(\mu_1 + \mu_2)} \left( \frac{\mu_1}{\mu_2} \right)^{k/2} I_k(2 \sqrt{\mu_1 \mu_2}) \quad \text{for integer } k\]

      where $I_k$ is the modified Bessel function of the first kind.

      Skellam(μ1, μ2)     # Skellam distribution for the difference between two Poisson variables,
                           # respectively with expected values μ1 and μ2.
       
      -params(d)           # Get the parameters, i.e. (μ1, μ2)

      External links:

      source
      Distributions.SolitonType
      Soliton(K::Integer, M::Integer, δ::Real, atol::Real=0) <: Distribution{Univariate, Discrete}

      The Robust Soliton distribution of length K, mode M (i.e., the location of the robust component spike), peeling process failure probability δ, and minimum non-zero probability mass atol. More specifically, degrees i for which pdf(Ω, i)<atol are set to 0. Letting atol=0 yields the regular robust Soliton distribution.

      Soliton(K, M, δ)        # Robust Soliton distribution (with atol=0)
      +params(d)           # Get the parameters, i.e. (μ1, μ2)

      External links:

      source
      Distributions.SolitonType
      Soliton(K::Integer, M::Integer, δ::Real, atol::Real=0) <: Distribution{Univariate, Discrete}

      The Robust Soliton distribution of length K, mode M (i.e., the location of the robust component spike), peeling process failure probability δ, and minimum non-zero probability mass atol. More specifically, degrees i for which pdf(Ω, i)<atol are set to 0. Letting atol=0 yields the regular robust Soliton distribution.

      Soliton(K, M, δ)        # Robust Soliton distribution (with atol=0)
       Soliton(K, M, δ, atol)  # Robust Soliton distribution with minimum non-zero probability mass atol
       
       params(Ω)               # Get the parameters ,i.e., (K, M, δ, atol)
      @@ -8657,4 +8657,4 @@
       pdf(Ω, i)               # Evaluate the pdf at i
       cdf(Ω, i)               # Evaluate the pdf at i
       rand(Ω)                 # Sample from Ω
      -rand(Ω, n)              # Draw n samples from Ω

      External links:

      source

      Vectorized evaluation

      Vectorized computation and in-place vectorized computation have been deprecated.

      Index

      • 1Lindley, D. V. (1958). Fiducial Distributions and Bayes' Theorem. Journal of the Royal Statistical Society: Series B (Methodological), 20(1), 102–107.
      • 2Ghitany, M. E., Atieh, B., & Nadarajah, S. (2008). Lindley distribution and its application. Mathematics and Computers in Simulation, 78(4), 493–506.
      +rand(Ω, n) # Draw n samples from Ω

      External links:

      source

      Vectorized evaluation

      Vectorized computation and in-place vectorized computation have been deprecated.

      Index