FunctionImputation | R Documentation |
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. Unlike
other decorators, private methods are added to the Distribution, not public methods.
Therefore the underlying public [Distribution]$pdf
, [Distribution]$pdf
,
[Distribution]$quantile
, and [Distribution]$rand
functions stay the same.
Decorator objects add functionality to the given Distribution object by copying methods in the decorator environment to the chosen Distribution environment.
All methods implemented in decorators try to exploit analytical results where possible, otherwise numerical results are used with a message.
distr6::DistributionDecorator
-> FunctionImputation
packages
Packages required to be installed in order to construct the distribution.
methods
Returns the names of the available methods in this decorator.
decorate()
Decorates the given distribution with the methods available in this decorator.
FunctionImputation$decorate(distribution, n = 1000)
distribution
Distribution
Distribution to decorate.
n
(integer(1))
Grid size for imputing functions, cannot be changed after decorating.
Generally larger n
means better accuracy but slower computation, and smaller n
means worse accuracy and faster computation.
clone()
The objects of this class are cloneable with this method.
FunctionImputation$clone(deep = FALSE)
deep
Whether to make a deep clone.
Other decorators:
CoreStatistics
,
ExoticStatistics
if (requireNamespace("GoFKernel", quietly = TRUE) && requireNamespace("pracma", quietly = TRUE)) { pdf <- function(x) ifelse(x < 1 | x > 10, 0, 1 / 10) x <- Distribution$new("Test", pdf = pdf, support = set6::Interval$new(1, 10, class = "integer"), type = set6::Naturals$new() ) decorate(x, "FunctionImputation", n = 1000) x <- Distribution$new("Test", pdf = pdf, support = set6::Interval$new(1, 10, class = "integer"), type = set6::Naturals$new(), decorators = "FunctionImputation" ) x <- Distribution$new("Test", pdf = pdf, support = set6::Interval$new(1, 10, class = "integer"), type = set6::Naturals$new() ) FunctionImputation$new()$decorate(x, n = 1000) x$pdf(1:10) x$cdf(1:10) x$quantile(0.42) x$rand(4) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.