A wrapper for truncating any probability distribution at given limits.
Returns an R6 object of class TruncatedDistribution.
TruncatedDistribution$new(distribution, lower = NULL, upper = NULL)
Argument | Type | Details |
distribution |
distribution | Distribution to truncate. |
lower |
numeric | Lower limit for truncation. |
Variable | Return |
name |
Name of distribution. |
short_name |
Id of distribution. |
description |
Brief description of distribution. |
Accessor Methods | Link |
wrappedModels(model = NULL) |
wrappedModels |
decorators() |
decorators |
traits() |
traits |
valueSupport() |
valueSupport |
variateForm() |
variateForm |
type() |
type |
properties() |
properties |
support() |
support |
symmetry() |
symmetry |
sup() |
sup |
inf() |
inf |
dmax() |
dmax |
dmin() |
dmin |
skewnessType() |
skewnessType |
kurtosisType() |
kurtosisType |
d/p/q/r Methods | Link |
pdf(x1, ..., log = FALSE, simplify = TRUE) |
pdf |
cdf(x1, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE) |
cdf |
quantile(p, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE) |
quantile.Distribution |
rand(n, simplify = TRUE) |
rand |
Statistical Methods | Link |
prec() |
prec |
stdev() |
stdev |
median() |
median.Distribution |
iqr() |
iqr |
cor() |
cor |
Parameter Methods | Link |
parameters(id) |
parameters |
getParameterValue(id, error = "warn") |
getParameterValue |
setParameterValue(..., lst = NULL, error = "warn") |
setParameterValue |
Validation Methods | Link |
liesInSupport(x, all = TRUE, bound = FALSE) |
liesInSupport |
liesInType(x, all = TRUE, bound = FALSE) |
liesInType |
Representation Methods | Link |
strprint(n = 2) |
strprint |
print(n = 2) |
print |
summary(full = T) |
summary.Distribution |
Truncates a distribution at lower and upper limits, using the formulae $$f_T(x) = f_X(x) / (F_X(upper) - F_X(lower))$$ $$F_T(x) = (F_X(x) - F_X(lower)) / (F_X(upper) - F_X(lower))$$ where \(f_T\)/\(F_T\) is the pdf/cdf of the truncated distribution T = Truncate(X, lower, upper) and \(f_X\), \(F_X\) is the pdf/cdf of the original distribution.
If lower or upper are NULL they are taken to be self$inf()
and self$sup()
respectively.
The support of the new distribution is the interval of points between lower and upper.
The pdf and cdf of the distribution are required for this wrapper, if unavailable decorate with
FunctionImputation
first.
# NOT RUN {
truncBin <- TruncatedDistribution$new(
Binomial$new(prob = 0.5, size = 10),
lower = 2, upper = 4)
truncBin$getParameterValue("prob")
# }
Run the code above in your browser using DataLab