This decorator imputes missing pdf/cdf/quantile/rand methods from R6 Distributions by using strategies dependent on which methods are already present in the distribution.


Returns a decorated R6 object inheriting from class SDistribution with d/p/q/r numerically imputed if previously missing.


Decorator objects add functionality to the given Distribution object by copying methods in the decorator environment to the chosen Distribution environment. See the 'Added Methods' section below to find details of the methods that are added to the Distribution. Methods already present in the distribution are not overwritten by the decorator.

Use decorate to decorate a Distribution.

All methods in this decorator use numerical approximations and therefore better results may be available from analytic computations.



Constructor Arguments

distributiondistributionDistribution to decorate.

Added Methods

pdf(x1, ..., log = FALSE, simplify = TRUE)Density/mass functionpdf
cdf(x1, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE)Distribution functioncdf
quantile(p, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE)Quantile functionquantile.Distribution
rand(n, simplify = TRUE)Simulation functionrand

See also


x = Distribution$new("Test", pdf = function(x) 1/(4-1), support = set6::Interval$new(1,4), type = set6::Reals$new()) decorate(x, FunctionImputation)
#> x is now decorated with FunctionImputation
#> Test
#> [1] 0.0000000 0.3333333 0.3333333 0.3333333 0.3333333 0.0000000
#> Results from numeric calculations are approximate only. Better results may be available.
#> [1] 0.0000000 0.0000000 0.3333333 0.6666667 1.0000000 1.0000000