Density, distribution function, quantile function and random generation for truncated distributions.
dtrunc(x, spec, a=-Inf, b=Inf, log=FALSE, ...)
extrunc(spec, a=-Inf, b=Inf, ...)
ptrunc(x, spec, a=-Inf, b=Inf, ...)
qtrunc(p, spec, a=-Inf, b=Inf, ...)
rtrunc(n, spec, a=-Inf, b=Inf, ...)
vartrunc(spec, a=-Inf, b=Inf, ...)
dtrunc
gives the density,
extrunc
gives the expectation,
ptrunc
gives the distribution function,
qtrunc
gives the quantile function,
rtrunc
generates random deviates, and
vartrunc
gives the variance of the truncated distribution.
This is a the number of random draws for rtrunc
.
This is a vector of probabilities.
This is a vector to be evaluated.
The base name of a probability distribution is
specified here. For example, to estimate the density of a
truncated normal distribution, enter norm
.
This is the lower bound of truncation, which defaults to negative infinity.
This is the upper bound of truncation, which defaults to infinity.
Logical. If log=TRUE
, then the logarithm of the
density is returned.
Additional arguments to pass.
A truncated distribution is a conditional distribution that results from a priori restricting the domain of some other probability distribution. More than merely preventing values outside of truncated bounds, a proper truncated distribution integrates to one within the truncated bounds. In contrast to a truncated distribution, a censored distribution occurs when the probability distribution is still allowed outside of a pre-specified range. Here, distributions are truncated to the interval \([a,b]\), such as \(p(\theta) \in [a,b]\).
The R code of Nadarajah and Kotz (2006) has been modified to work with log-densities. This code was also available in the (extinct) package LaplacesDemon.
Nadarajah, S. and Kotz, S. (2006). "R Programs for Computing Truncated Distributions". Journal of Statistical Software, 16, Code Snippet 2, p. 1--8.
lqr
,
SKD
.
x <- seq(-0.5, 0.5, by = 0.1)
y <- dtrunc(x, "norm", a=-0.5, b=0.5, mean=0, sd=2)
Run the code above in your browser using DataLab