Learn R Programming

distr6 (version 1.3.6)

Dirichlet: Dirichlet Distribution Class

Description

Mathematical and statistical functions for the Dirichlet distribution, which is commonly used as a prior in Bayesian modelling and is multivariate generalisation of the Beta distribution.

Value

Returns an R6 object inheriting from class SDistribution.

Constructor

Dirichlet$new(params = c(1, 1), decorators = NULL, verbose = FALSE)

Constructor Arguments

Argument Type Details
params numeric vector of concentration parameters.

decorators Decorator decorators to add functionality. See details.

Constructor Details

The Dirichlet distribution is parameterised with params as a vector of positive numerics. The parameter K is automatically calculated by counting the length of the params vector, once constructed this cannot be changed.

Public Variables

Variable Return
name Name of distribution.
short_name Id of distribution.
description Brief description of distribution.

Public Methods

Accessor Methods Link
decorators decorators
traits traits
valueSupport valueSupport
variateForm variateForm
type type
properties properties
support support
symmetry symmetry
sup sup
inf inf
dmax dmax
dmin dmin
skewnessType skewnessType
kurtosisType kurtosisType

Statistical Methods Link pdf(x1, ..., log = FALSE, simplify = TRUE) pdf cdf(x1, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE) cdf quantile(p, ..., lower.tail = TRUE, log.p = FALSE, simplify = TRUE) quantile.Distribution rand(n, simplify = TRUE) rand mean() mean.Distribution variance() variance stdev() stdev prec() prec cor() cor skewness() skewness kurtosis(excess = TRUE) kurtosis entropy(base = 2) entropy mgf(t) mgf cf(t) cf pgf(z) pgf median() median.Distribution iqr() iqr mode(which = "all") mode

Parameter Methods Link parameters(id) parameters getParameterValue(id, error = "warn") getParameterValue setParameterValue(..., lst = NULL, error = "warn") setParameterValue

Validation Methods Link liesInSupport(x, all = TRUE, bound = FALSE) liesInSupport liesInType(x, all = TRUE, bound = FALSE) liesInType

Representation Methods Link strprint(n = 2) strprint print(n = 2) print summary(full = T) summary.Distribution

Details

The Dirichlet distribution parameterised with concentration parameters, \(\alpha_1,...,\alpha_k\), is defined by the pdf, $$f(x_1,...,x_k) = (\prod \Gamma(\alpha_i))/(\Gamma(\sum \alpha_i))\prod(x_i^{\alpha_i - 1})$$ for \(\alpha = \alpha_1,...,\alpha_k; \alpha > 0\), where \(\Gamma\) is the gamma function.

The distribution is supported on \(x_i \ \epsilon \ (0,1), \sum x_i = 1\).

mgf and cf are omitted as no closed form analytic expression could be found, decorate with CoreStatistics for numerical results. cdf and quantile are omitted as no closed form analytic expression could be found, decorate with FunctionImputation for a numerical imputation.

Sampling is performed via sampling independent Gamma distributions and normalising the samples (Devroye, 1986).

References

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

Devroye, Luc (1986). Non-Uniform Random Variate Generation. Springer-Verlag. ISBN 0-387-96305-7.

See Also

listDistributions for all available distributions. Beta for the Beta distribution. CoreStatistics for numerical results. FunctionImputation to numerically impute d/p/q/r.

Examples

Run this code
# NOT RUN {
# Different parameterisations
x <- Dirichlet$new(params = c(2,5,6))

# Update parameters
x$setParameterValue(params = c(3, 2, 3))
# 'K' parameter is automatically calculated
x$parameters()
# }
# NOT RUN {
# This errors as less than three parameters supplied
x$setParameterValue(params = c(1, 2))
# }
# NOT RUN {
# d/p/q/r
# Note the difference from R stats
x$pdf(0.1, 0.4, 0.5)
# This allows vectorisation:
x$pdf(c(0.3, 0.2), c(0.6, 0.9), c(0.9,0.1))
x$rand(4)

# Statistics
x$mean()
x$variance()

summary(x)

# }

Run the code above in your browser using DataLab