Truncated Distributions

The package provides the truncated function which creates the most appropriate distribution to represent a truncated version of a given distribution.

A truncated distribution can be constructed using the following signature:

Distributions.truncatedFunction
truncated(d::UnivariateDistribution, l::Real, u::Real)

Truncate a univariate distribution d to the interval [l, u].

The lower bound l can be finite or -Inf and the upper bound u can be finite or Inf. The function throws an error if l > u.

The function falls back to constructing a Truncated wrapper.

Implementation

To implement a specialized truncated form for distributions of type D, the method truncate(d::D, l::T, u::T) where {T <: Real} should be implemented.

source

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

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

Distributions.TruncatedNormalFunction
TruncatedNormal(mu, sigma, l, u)

The truncated normal distribution is a particularly important one in the family of truncated distributions. We provide additional support for this type with TruncatedNormal which calls Truncated(Normal(mu, sigma), l, u). Unlike the general case, truncated normal distributions support mean, mode, modes, var, std, and entropy.

source