Distribution {rdecision} | R Documentation |
A probability distribution
Description
An R6 class representing a (possibly multivariate) distribution.
Details
The base class for particular univariate or multivariate distributions.
Methods
Public methods
Method new()
Create an object of class Distribution
.
Usage
Distribution$new(name, K = 1L)
Arguments
name
Name of the distribution ("Beta" etc.)
K
Order of the distribution (1 = univariate, 2 = bivariate etc.). Must be an integer; use 1L, 3L etc. to avoid an error.
Returns
An object of class Distribution
.
Method order()
Order of the distribution
Usage
Distribution$order()
Returns
Order (K
).
Method distribution()
Description of the uncertainty distribution.
Usage
Distribution$distribution()
Details
Includes the distribution name and its parameters.
Returns
Distribution name and parameters as character string.
Method mean()
Mean value of the distribution.
Usage
Distribution$mean()
Returns
Mean value as a numeric scalar (K = 1L
) or vector of
length K
.
Method mode()
Return the mode of the distribution.
Usage
Distribution$mode()
Details
By default returns NA
, which will be the case for most
because an arbitrary distribution is not guaranteed to be unimodal.
Returns
Mode as a numeric scalar (K = 1L
) or vector of
length K
.
Method SD()
Return the standard deviation of a univariate distribution.
Usage
Distribution$SD()
Details
Only defined for univariate (K = 1L
) distributions; for
multivariate distributions, function varcov
returns the
variance-covariance matrix.
Returns
Standard deviation as a numeric value.
Method varcov()
Variance-covariance matrix.
Usage
Distribution$varcov()
Returns
A positive definite symmetric matrix of size K
by
K
, or a scalar for K = 1L
, equal to the variance.
Method quantile()
Marginal quantiles of the distribution.
Usage
Distribution$quantile(probs)
Arguments
probs
Numeric vector of probabilities, each in range [0,1].
Details
If they are defined, this function returns the marginal
quantiles of the multivariate distribution; i.e. the quantiles of each
univariate marginal distribution of the multivariate distribution. For
example, the univariate marginal distributions of a multivariate
normal are univariate normals, and the univariate marginal distributions
of a Dirichlet distribution are Beta distributions. Note that these are
not the true quantiles of a multivariate distribution, which are contours
for K = 2L
, surfaces for K = 3L
, etc. For example, the
2.5% and 97.5% marginal quantiles of a bivariate normal distribution
define a rectangle in x_1, x_2
space that will include more than
95% of the distribution, whereas the contour containing 95% of the
distribution is an ellipse.
Returns
For K = 1L
a numeric vector of length equal to the length
of probs
, with each entry labelled with the quantile. For
K > 1L
a matrix of numeric values with the number of rows equal
to the length of probs
, the number of columns equal to the order;
rows are labelled with probabilities and columns with the dimension
(1, 2, etc).
Method sample()
Draw and hold a random sample from the distribution.
Usage
Distribution$sample(expected = FALSE)
Arguments
expected
If TRUE, sets the next value retrieved by a call to
r()
to be the mean of the distribution.
Returns
Void
Method r()
Return a random sample drawn from the distribution.
Usage
Distribution$r()
Details
Returns the sample generated at the last call to sample
.
Returns
A vector of length K
representing one sample.
Method clone()
The objects of this class are cloneable with this method.
Usage
Distribution$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Author(s)
Andrew J. Sims andrew.sims@newcastle.ac.uk