A wrapper for truncating any probability distribution at given limits.
The pdf and cdf of the distribution are required for this wrapper, if unavailable decorate with FunctionImputation first.
Truncates a distribution at lower and upper limits on a left-open interval, 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. T is supported on (].
distr6::Distribution
-> distr6::DistributionWrapper
-> TruncatedDistribution
properties
Returns distribution properties, including skewness type and symmetry.
Inherited methods
distr6::Distribution$cdf()
distr6::Distribution$confidence()
distr6::Distribution$correlation()
distr6::Distribution$getParameterValue()
distr6::Distribution$iqr()
distr6::Distribution$liesInSupport()
distr6::Distribution$liesInType()
distr6::Distribution$median()
distr6::Distribution$parameters()
distr6::Distribution$pdf()
distr6::Distribution$prec()
distr6::Distribution$print()
distr6::Distribution$quantile()
distr6::Distribution$rand()
distr6::Distribution$setParameterValue()
distr6::Distribution$stdev()
distr6::Distribution$strprint()
distr6::Distribution$summary()
distr6::Distribution$workingSupport()
distr6::DistributionWrapper$wrappedModels()
new()
Creates a new instance of this R6 class.
TruncatedDistribution$new(distribution, lower = NULL, upper = NULL)
distribution
([Distribution])
Distribution to wrap.
lower
(numeric(1))
Lower limit to huberize the distribution at. If NULL
then the lower bound of
the Distribution is used.
upper
(numeric(1))
Upper limit to huberize the distribution at. If NULL
then the upper bound of
the Distribution is used.
TruncatedDistribution$new(
Binomial$new(prob = 0.5, size = 10),
lower = 2, upper = 4
)
# alternate constructor
truncate(Binomial$new(), lower = 2, upper = 4)
## ------------------------------------------------
## Method `TruncatedDistribution$new`
## ------------------------------------------------
TruncatedDistribution$new(
Binomial$new(prob = 0.5, size = 10),
lower = 2, upper = 4
)
#> TruncBinom(Binom__prob = 0.5, Binom__size = 10, trunc__lower = 2, trunc__upper = 4)
# alternate constructor
truncate(Binomial$new(), lower = 2, upper = 4)
#> TruncBinom(Binom__prob = 0.5, Binom__size = 10, trunc__lower = 2, trunc__upper = 4)