# 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.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 such that 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.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
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

### 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]

params(d)        # Get the parameters, i.e. (a, b)
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

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

source
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. (α, β)

source
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. (α, β)

source
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)
Cauchy(μ, σ)     # Cauchy 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
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. ν

source
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(k/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. ν

source
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

source
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 / θ

source
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)

source
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)
Frechet(α)       # Fréchet distribution with shape α and unit scale, i.e. Frechet(α, 1)
Frechet(α, θ)    # Fréchet distribution with shape α and scale θ

params(d)        # Get the parameters, i.e. (α, θ)
shape(d)         # Get the shape parameter, i.e. α
scale(d)         # Get the scale parameter, i.e. θ

source
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)
Gamma(α)         # Gamma distribution with shape α and unit scale, i.e. Gamma(α, 1)
Gamma(α, θ)      # Gamma distribution with shape α and scale θ

params(d)        # Get the parameters, i.e. (α, θ)
shape(d)         # Get the shape parameter, i.e. α
scale(d)         # Get the scale parameter, i.e. θ

source
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 \\ \frac{1}{\sigma} \exp\left\{-\frac{x-\mu}{\sigma}\right\} \exp\left\{-\exp\left[-\frac{x-\mu}{\sigma}\right]\right\} & \text{for } \xi = 0 \\ \end{cases}$$$

for

$$$x \in \begin{cases} \left[ \mu - \frac{\sigma}{\xi}, + \infty \right) & \text{for } \xi > 0 \\ \left( - \infty, + \infty \right) & \text{for } \xi = 0 \\ \left( - \infty, \mu - \frac{\sigma}{\xi} \right] & \text{for } \xi < 0 \end{cases}$$$
GeneralizedExtremeValue(μ, σ, ξ)      # Generalized Pareto distribution with shape ξ, scale σ and location μ.

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)

source
Distributions.GeneralizedParetoType
GeneralizedPareto(μ, σ, ξ)

The Generalized Pareto distribution 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 \\ \frac{1}{\sigma} e^{-\frac{\left( x - \mu \right) }{\sigma}} & \text{for } \xi = 0 \end{cases}~, \quad x \in \begin{cases} \left[ \mu, \infty \right] & \text{for } \xi \geq 0 \\ \left[ \mu, \mu - \sigma / \xi \right] & \text{for } \xi < 0 \end{cases}$$$
GeneralizedPareto()             # Generalized Pareto distribution with unit shape and unit scale, i.e. GeneralizedPareto(0, 1, 1)
GeneralizedPareto(μ, σ)         # Generalized Pareto distribution with shape ξ and scale σ, i.e. GeneralizedPareto(0, σ, ξ)
GeneralizedPareto(μ, σ, ξ)      # Generalized Pareto distribution with shape ξ, scale σ and location μ.

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. ξ

source
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)
Gumbel(μ)           # Gumbel distribution with location μ and unit scale, i.e. Gumbel(μ, 1)
Gumbel(μ, θ)        # Gumbel 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
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)
InverseGamma(α)       # Inverse Gamma distribution with shape α and unit scale, i.e. InverseGamma(α, 1)
InverseGamma(α, θ)    # Inverse Gamma distribution with shape α and scale θ

params(d)        # Get the parameters, i.e. (α, θ)
shape(d)         # Get the shape parameter, i.e. α
scale(d)         # Get the scale parameter, i.e. θ

source
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)
InverseGaussian(μ),            # Inverse Gaussian distribution with mean μ and unit shape, i.e. InverseGaussian(μ, 1)
InverseGaussian(μ, λ)          # Inverse Gaussian distribution with mean μ and shape λ

params(d)           # Get the parameters, i.e. (μ, λ)
mean(d)             # Get the mean parameter, i.e. μ
shape(d)            # Get the shape parameter, i.e. λ

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.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)
Laplace(μ, θ)   # Laplace 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
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)
Levy(μ)        # Levy distribution with location μ and unit scale, i.e. Levy(μ, 1)
Levy(μ, σ)     # Levy distribution with location μ and scale σ

params(d)      # Get the parameters, i.e. (μ, σ)
location(d)    # Get the location parameter, i.e. μ

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)
Logistic(μ)      # Logistic distribution with location μ and unit scale, i.e. Logistic(μ, 1)
Logistic(μ, θ)   # Logistic 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
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), \quad x > 0$$$

where the logit-Function is

$$$\text{logit}(x) = \ln\left(\frac{x}{1-x}\right) \quad 0 < x < 1$$$
LogitNormal()        # Logit-normal distribution with zero logit-mean and unit scale
LogitNormal(μ)       # Logit-normal distribution with logit-mean μ and unit scale
LogitNormal(μ, σ)    # Logit-normal distribution with logit-mean μ and scale σ

params(d)            # Get the parameters, i.e. (μ, σ)
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.

source
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), \quad x > 0$$$
LogNormal()          # Log-normal distribution with zero log-mean and unit scale
LogNormal(μ)         # Log-normal distribution with log-mean mu and unit scale
LogNormal(μ, σ)      # Log-normal distribution with log-mean mu and scale sig

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. σ

source
Distributions.LogUniformType
LogUniform(a,b)

A positive random variable X is log-uniformly with parameters a and b if the logarithm of X is Uniform(log(a), log(b)). The log uniform distribution is also known as reciprocal distribution.

LogUniform(1,10)

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. (ν, λ)

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.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
Normal(μ)         # Normal distribution with mean μ and unit variance
Normal(μ, σ)      # Normal distribution with mean μ and variance σ^2

params(d)         # Get the parameters, i.e. (μ, σ)
mean(d)           # Get the mean, i.e. μ
std(d)            # Get the standard deviation, i.e. σ

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.

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)
Pareto(α, θ)        # Pareto distribution with shape α and scale θ

params(d)        # Get the parameters, i.e. (α, θ)
shape(d)         # Get the shape parameter, i.e. α
scale(d)         # Get the scale parameter, i.e. θ

source
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 and Laplacian distributions as special cases where p = 1 and p = 2. As p → ∞, the distribution approaches the Uniform distribution on [μ-α, μ+α].

PGeneralizedGaussian()           # GGD with shape 2, scale 1, location 0, (the Normal distribution)
PGeneralizedGaussian(μ, α, p)    # GGD with location μ, scale α, and shape p

params(d)                       # Get the parameters, i.e. (μ, α, p)
shape(d)                        # Get the shape parameter, p
scale(d)                        # Get the scale parameter, α
location(d)                     # Get the location parameter, μ

source
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. σ

source
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σ²

source
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,)

source
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} \frac{1}{\sigma 2p^{1/p}\Gamma(1+1/p)} \exp \left\{ - \frac{1}{2p}\Big| \frac{x-\mu}{\alpha \sigma} \Big|^p \right\}, & \text{if } x \leq \mu \\ \frac{1}{\sigma 2p^{1/p}\Gamma(1+1/p)} \exp \left\{ - \frac{1}{2p}\Big| \frac{x-\mu}{(1-\alpha) \sigma} \Big|^p \right\}, & \text{if } x > \mu \end{cases}.$$$

The Skewed exponential power distribution (SEPD) incorporates the Laplace ($p=1, \alpha=0.5$), normal ($p=2, \alpha=0.5$), uniform ($p\rightarrow \infty, \alpha=0.5$), asymmetric Laplace ($p=1$), skew normal ($p=2$), and exponential power distribution ($\alpha = 0.5$) as special cases.

[1] Zhy, D. and V. Zinde-Walsh (2009). Properties and estimation of asymmetric exponential power distribution. Journal of econometrics, 148(1):86-96, 2009.

SkewedExponentialPower()            # SEPD with shape 2, scale 1, location 0, and skewness 0.5 (the standard normal distribution)
SkewedExponentialPower(μ, σ, p, α)  # SEPD with location μ, scale σ, shape p, and skewness α
SkewedExponentialPower(μ, σ, p)     # SEPD with location μ, scale σ, shape p, and skewness 0.5 (the exponential power distribution)
SkewedExponentialPower(μ, σ)        # SEPD with location μ, scale σ, shape 2, and skewness 0.5 (the normal distribution)
SkewedExponentialPower(μ)           # SEPD with location μ, scale 1, shape 2, and skewness 0.5 (the normal distribution)

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
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$$$

source
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)

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
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. ν

Student's T distribution on Wikipedia

source
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, \\ \frac{2(x-a)}{(b-a)(c-a)} & \mathrm{for\ } a \le x \leq c, \\[4pt] \frac{2(b-x)}{(b-a)(b-c)} & \mathrm{for\ } c < x \le b, \\[4pt] 0 & \mathrm{for\ } b < x, \end{cases}$$$
TriangularDist(a, b)        # Triangular distribution with lower limit a, upper limit b, and mode (a+b)/2
TriangularDist(a, b, c)     # Triangular distribution with lower limit a, upper limit b, and mode c

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

source
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]

params(d)        # Get the parameters, i.e. (a, b)
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

source
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 κ

source
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)
Weibull(α)       # Weibull distribution with shape α and unit scale, i.e. Weibull(α, 1)
Weibull(α, θ)    # Weibull distribution with shape α and scale θ

params(d)        # Get the parameters, i.e. (α, θ)
shape(d)         # Get the shape parameter, i.e. α
scale(d)         # Get the scale parameter, i.e. θ

source

## 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, \\ p & \quad \text{for } k = 1. \end{cases}$$$
Bernoulli()    # Bernoulli distribution with p = 0.5
Bernoulli(p)   # Bernoulli 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

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}$$$

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

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

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.

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

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

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

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

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)

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

Note: The definition of the negative binomial distribution in Wolfram is different from the Wikipedia definition. In Wikipedia, r is the number of failures and k is the number of successes.

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. λ

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

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)

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)
degrees(Ω)              # Return a vector composed of the degrees with non-zero probability mass
pdf(Ω, i)               # Evaluate the pdf at i
cdf(Ω, i)               # Evaluate the pdf at i
rand(Ω)                 # Sample from Ω
rand(Ω, n)              # Draw n samples from Ω