This decorator adds numeric methods for missing analytic expression in distr6 Distribution objects as well as adding generalised expectation and moments functions.

Value

Returns a decorated R6 object inheriting from class SDistribution with the methods listed below added to the SDistribution methods.

Details

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

CoreStatistics$new(distribution)

Constructor Arguments

ArgumentTypeDetails
distributiondistributionDistribution to decorate.

Added Methods

MethodNameLink
mgf(t)Moment generating functionmgf
pgf(t)Probability generating functionpgf
cf(t)Characteristic functioncf
entropy(base = 2)(Shannon) Entropyentropy
skewness()Skewnessskewness
kurtosis(excess = TRUE)Kurtosiskurtosis
kthmoment(type = "central")Kth Momentkthmoment
genExp(trafo)Generalised ExpectationgenExp
mode(which = "all")Modemode
variance()Variancevariance
mean()Arithmetic meanmean.Distribution

See also

Examples

x = Binomial$new() decorate(x, CoreStatistics)
#> x is now decorated with CoreStatistics
#> Binom(prob = 0.5, size = 10)
x$genExp()
#> [1] 5
x = Binomial$new(decorators = CoreStatistics) x$kthmoment(4)
#> Results from numeric calculations are approximate only. Better results may be available.
#> [1] 17.5