FunctionImputation | R Documentation |

## Imputed Pdf/Cdf/Quantile/Rand Functions Decorator

### Description

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.

### Details

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.

### Super class

`distr6::DistributionDecorator`

-> `FunctionImputation`

### Public fields

`packages`

Packages required to be installed in order to construct the distribution.

### Active bindings

`methods`

Returns the names of the available methods in this decorator.

### Methods

#### Public methods

## Inherited methods

#### Method `decorate()`

Decorates the given distribution with the methods available in this decorator.

##### Usage

FunctionImputation$decorate(distribution, n = 1000)

##### Arguments

`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.

#### Method `clone()`

The objects of this class are cloneable with this method.

##### Usage

FunctionImputation$clone(deep = FALSE)

##### Arguments

`deep`

Whether to make a deep clone.

### See Also

Other decorators:
`CoreStatistics`

,
`ExoticStatistics`

### Examples

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)
}