Truncated Distributions

Truncated Distributions

The package provides a type, named Truncated, to represented truncated distributions, which is defined as below:

immutable Truncated{D<:UnivariateDistribution,S<:ValueSupport} <: Distribution{Univariate,S}
    untruncated::D      # the original distribution (untruncated)
    lower::Float64      # lower bound
    upper::Float64      # upper bound
    lcdf::Float64       # cdf of lower bound
    ucdf::Float64       # cdf of upper bound

    tp::Float64         # the probability of the truncated part, i.e. ucdf - lcdf
    logtp::Float64      # log(tp), i.e. log(ucdf - lcdf)
end

A truncated distribution can be constructed using the constructor Truncated as follows:

Truncated(d, l, u):

Construct a truncated distribution.

Arguments

  • d::UnivariateDistribution: The original distribution.

  • l::Real: The lower bound of the truncation, which can be a finite value or -Inf.

  • u::Real: The upper bound of the truncation, which can be a finite value of Inf.

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.

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