Mathematical and statistical functions for the EmpiricalMV distribution, which is commonly used in sampling such as MCMC.

Value

Returns an R6 object inheriting from class SDistribution.

Details

The EmpiricalMV distribution is defined by the pmf, $$p(x) = \sum I(x = x_i) / k$$ for \(x_i \epsilon R, i = 1,...,k\).

Sampling from this distribution is performed with the sample function with the elements given as the support set and uniform probabilities. Sampling is performed with replacement, which is consistent with other distributions but non-standard for Empirical distributions. Use simulateEmpiricalDistribution to sample without replacement.

The cdf assumes that the elements are supplied in an indexed order (otherwise the results are meaningless).

Distribution support

The distribution is supported on \(x_1,...,x_k\).

Default Parameterisation

EmpMV(data = data.frame(1, 1))

Omitted Methods

N/A

Also known as

N/A

References

McLaughlin, M. P. (2001). A compendium of common probability distributions (pp. 2014-01). Michael P. McLaughlin.

Super classes

distr6::Distribution -> distr6::SDistribution -> EmpiricalMV

Public fields

name

Full name of distribution.

short_name

Short name of distribution for printing.

description

Brief description of the distribution.

alias

Alias of the distribution.

Methods

Inherited methods


Method new()

Creates a new instance of this R6 class.

Usage

EmpiricalMV$new(data = NULL, decorators = NULL)

Arguments

data

[matrix]
Matrix-like object where each column is a vector of observed samples corresponding to each variable.

decorators

(character())
Decorators to add to the distribution during construction.

Examples

EmpiricalMV$new(MultivariateNormal$new()$rand(100))


Method mean()

The arithmetic mean of a (discrete) probability distribution X is the expectation $$E_X(X) = \sum p_X(x)*x$$ with an integration analogue for continuous distributions.

Usage

EmpiricalMV$mean(...)

Arguments

...

Unused.


Method variance()

The variance of a distribution is defined by the formula $$var_X = E[X^2] - E[X]^2$$ where \(E_X\) is the expectation of distribution X. If the distribution is multivariate the covariance matrix is returned.

Usage

EmpiricalMV$variance(...)

Arguments

...

Unused.


Method setParameterValue()

Sets the value(s) of the given parameter(s).

Usage

EmpiricalMV$setParameterValue(
  ...,
  lst = NULL,
  error = "warn",
  resolveConflicts = FALSE
)

Arguments

...

ANY
Named arguments of parameters to set values for. See examples.

lst

(list(1))
Alternative argument for passing parameters. List names should be parameter names and list values are the new values to set.

error

(character(1))
If "warn" then returns a warning on error, otherwise breaks if "stop".

resolveConflicts

(logical(1))
If FALSE (default) throws error if conflicting parameterisations are provided, otherwise automatically resolves them by removing all conflicting parameters.


Method clone()

The objects of this class are cloneable with this method.

Usage

EmpiricalMV$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples


## ------------------------------------------------
## Method `EmpiricalMV$new`
## ------------------------------------------------

EmpiricalMV$new(MultivariateNormal$new()$rand(100))
#> EmpMV(data = list(V1 = c(-0.526692630351283, -2.49536480915438, 0.350492383702827, 0.765906802532555, -0.136943428599099, 1.51974446834724, -0.0536715061508017, -0.743908962797543, -0.560829227031403, 0.748850942267306, 0.236095846759048, 0.417925675737717, -0.506286298229541, -0.948705722886941, -0.795201560474224, -1.22245109721962, -1.48926081390287, -0.942554006091392, 1.33644679792075, 0.666537819756823, 1.17005616766354, 1.10170809633169, -0.864349802977735, -0.0370514646718219, -0.499355411832378, -0.174245957308514, 
#> -0.945985005280397, 0.876913144878748, -1.13761275625578, -0.494143476387761, 0.791534123645639, 0.612722103889784, 0.88862899272379, 0.22533951485482, -1.22248707000132, -0.7510122231567, 0.352010126334829, 0.104662226933443, -0.61104608224538, 0.534803326058771, -1.22250157411617, 0.465165158411011, -0.130264800618813, -0.364851004324683, 0.413154817794422, -2.17995674203001, -0.357528324755672, -0.0501418010657054, -0.632587542022358, -0.235475907427546, -1.50338214597175, -0.753198229350471, 
#> 1.00578284651542, 2.3225565395417, 0.0488144355095131, -0.785235068436928, 0.68187803211519, -1.51060172429041, -2.02291845445234, 0.550015549139052, 0.893165019997801, 0.605884808224899, -0.520796372779794, -0.63589413738825, 1.17691424810852, 2.27295476618215, -1.99903913349767, -0.378407395180984, -1.5410302916367, -0.0201081842355959, 0.88986535907593, 0.445750348302804, -0.0201100267710495, 0.264661744879649, -0.183388482515322, -0.186553842004526, -1.6405816724151, 1.75433696088715, 1.01671328819622, 
#> -1.07806726465165, -0.52964367726925, -0.202447558737144, -1.03377323651804, -0.046400637310866, 0.416260797910689, 0.0639187530308365, 0.901335290053489, 0.668221203714885, 0.128688091789133, 0.202360673484458, 0.361694761427865, 0.372698962423058, -0.0516945386722141, 0.549899522976571, 0.684360080826633, -1.78436472417652, 0.830147723263884, -0.122186361074584, -0.961276679679037, -0.545401573002851), V2 = c(-0.0951349075760237, 0.166889216632368, 1.43370100928187, 1.16752066984205, -0.514902043516776, 
#> -0.328491677605083, -0.563524634833966, -0.109041651464962, 0.188001548963977, -1.91653831649921, 0.628953415243992, 1.97675847664655, -1.10996885267932, 0.476843756716056, 0.234326922506296, -2.45364735388403, -0.432147734134632, -0.121450799414898, -0.860356181774122, -1.42153474570427, -1.40471454250678, 0.697986262544779, -1.09147035108868, 0.810053792383895, 0.948031587815801, -1.10623595233741, 0.289089591304068, -1.14890393973024, -1.43724673508534, 0.840801808081863, -0.168848948069648, -0.771158924361937, 
#> 0.0132144768460245, -0.729915209602175, 0.406805171157349, -0.162116540339154, -0.28905829997927, 0.720186530653959, -1.10691407158303, 0.736067967856697, 1.02141530978363, 0.790472704523132, -0.930285333605259, 0.153872493250671, 2.4808233597049, 0.420874577554014, -0.646861513586719, 0.416942846990301, 1.15014667345879, -1.64310738628558, -2.05058484718271, -0.134141958474824, 2.16718679846135, -1.02042339064488, -0.771888628161592, -0.726603030794874, -0.229843287173231, -0.583727687120599, 0.403504676138385, 
#> 0.0283571217755485, -0.376555495773104, -0.00487472568702639, -0.639018597908028, 0.106586975364598, 0.447391153397406, 0.136058206021325, -0.420500870203527, 1.22077478856746, -0.310310122156193, -2.3902003364285, -1.48281332468633, 1.36977585585092, -0.109217587430481, 0.303848263845439, 0.559649672136207, -0.81227537165771, 0.507922477794402, 0.59240020189409, 0.121620585744186, -1.14356571956783, -0.681273155856935, 1.68449572050523, -0.155976673321198, -0.953628726504224, 0.114029609050454, 
#> -0.919332238270361, -0.79772829746059, 0.155214295636058, -1.53306545321898, -0.717538652532261, 1.39900429351273, -1.56564429428522, 0.514082103022085, 0.867816913024197, -0.162679977016422, -1.03714556605811, 0.60734694486578, 0.933125139463173, 0.255081706598915, 0.930360735887222)))