Learn R Programming

LaplacesDemon (version 16.1.1)

dist.Dirichlet: Dirichlet Distribution

Description

This is the density function and random generation from the Dirichlet distribution.

Usage

ddirichlet(x, alpha, log=FALSE)
rdirichlet(n, alpha)

Arguments

x

This is a vector containing a single deviate or matrix containing one random deviate per row. Each vector, or matrix row, must sum to 1.

n

This is the number of random deviates to generate.

alpha

This is a vector or matrix of shape parameters.

log

Logical. If log=TRUE, then the logarithm of the density is returned.

Value

ddirichlet gives the density and rdirichlet generates random deviates.

Details

  • Application: Continuous Multivariate

  • Density: $$p(\theta) = \frac{\gamma(\alpha_1 + \dots + \alpha_k)}{\gamma \alpha_1 \dots \gamma \alpha_k} \theta^{(\alpha[1]-1)}_1 \dots \theta^{(\alpha[k]-1)}_k, \quad \theta_1, \dots, \theta_k > 0, \quad \sum^k_{j=1} \theta_j = 1$$

  • Inventor: Johann Peter Gustav Lejeune Dirichlet (1805-1859)

  • Notation 1: \(\theta \sim\) Dirichlet(\(\alpha_1,\dots,\alpha_k\))

  • Notation 2: \(p(\theta) =\) Dirichlet(\(\theta | \alpha_1,\dots,\alpha_k\))

  • Notation 3: \(\theta \sim \mathcal{DIR}(\alpha_1,\dots,\alpha_k)\)

  • Notation 4: \(p(\theta) = \mathcal{DIR}(\theta | \alpha_1,\dots,\alpha_k)\)

  • Parameter: 'prior sample sizes' \(\alpha_j > 0, \alpha_0 = \sum^k_{j=1} \alpha_j\)

  • Mean: \(E(\theta_j) = \frac{\alpha_j}{\alpha_0}\)

  • Variance: \(var(\theta_j) = \frac{\alpha_j (\alpha_0 - \alpha_j)}{\alpha^2_0 (\alpha_0 + 1)}\)

  • Covariance: \(cov(\theta_i, \theta_j) = - \frac{\alpha_i \alpha_j}{\alpha^2_0 (\alpha_0 + 1)}\)

  • Mode: \(mode(\theta_j) = \frac{\alpha_j - 1}{\alpha_0 - k}\)

The Dirichlet distribution is the multivariate generalization of the univariate beta distribution. Its probability density function returns the belief that the probabilities of \(k\) rival events are \(\theta_j\) given that each event has been observed \(\alpha_j - 1\) times.

The Dirichlet distribution is commonly used as a prior distribution in Bayesian inference. The Dirichlet distribution is the conjugate prior distribution for the parameters of the categorical and multinomial distributions.

A very common special case is the symmetric Dirichlet distribution, where all of the elements in parameter vector \(\alpha\) have the same value. Symmetric Dirichlet distributions are often used as vague or weakly informative Dirichlet prior distributions, so that one component is not favored over another. The single value that is entered into all elements of \(\alpha\) is called the concentration parameter.

See Also

dbeta, dcat, dmvpolya, dmultinom, and TransitionMatrix.

Examples

Run this code
# NOT RUN {
library(LaplacesDemon)
x <- ddirichlet(c(.1,.3,.6), c(1,1,1))
x <- rdirichlet(10, c(1,1,1))
# }

Run the code above in your browser using DataLab