Censored Distributions
In censoring of data, values exceeding an upper limit (right censoring) or falling below a lower limit (left censoring), or both (interval censoring) are replaced by the corresponding limit itself. The package provides the censored
function, which creates the most appropriate distribution to represent a censored version of a given distribution.
A censored distribution can be constructed using the following signature:
#
Distributions.censored
— Function
censored(d0::UnivariateDistribution; [lower::Real], [upper::Real])
censored(d0::UnivariateDistribution, lower::Real, upper::Real)
A censored distribution d
of a distribution d0
to the interval =][lower, upper]
has the probability density (mass) function:
where
If X = clamp(Z, l, u)
, then
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:
-
censored(d0::D, l::T, u::T) where {T <: Real}
-
censored(d0::D, ::Nothing, u::Real)
-
censored(d0::D, l::Real, ::Nothing)
In the general case, this will create a Distributions.Censored{typeof(d0)}
structure, defined as follows:
#
Distributions.Censored
— Type
Censored
Generic wrapper for a censored
distribution.
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:
-
DiscreteUniform
-
Exponential
-
LogUniform
-
Normal
-
Uniform
mode
is not implemented for censored distributions.