R: Dirichlet Distribution

dist.Dirichlet {LaplacesDemon} | R Documentation

## 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.

### Details

- Application: Continuous Multivariate

- Density:

  p(theta) = (gamma(alpha[1] + ... + alpha[k]) / (gamma(alpha[1]) ... gamma(alpha[k]))) * theta[1]^(alpha[1] - 1) ... theta[k]^(alpha[k] - 1) theta[1],...,theta[k] >= 0, (the sum of j=1 to k of) theta[j] = 1

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

- Notation 1: theta ~ Dirichlet(alpha[1],..., alpha[k])

- Notation 2: p(theta) = Dirichlet(theta | alpha[1],...,alpha[k])

- Notation 3: theta ~ Dir(alpha[1],..., alpha[k])

- Notation 4: p(theta) = Dir(theta | alpha[1],...,alpha[k])

- Parameter: 'prior sample sizes' alpha[j] > 0, alpha[0] = (the sum from j=1 to k of) alpha[j]

- Mean: E(theta[j]) = alpha[j] / alpha[0]

- Variance: var(theta[j]) = (alpha[j] * (alpha[0] - alpha[j])) / (alpha[0]^2 * (alpha[0]+ 1))

- Covariance: cov(theta[i], theta[j]) = - ((alpha[i]*alpha[j]) / (alpha[0]^2 * (alpha[0] + 1)))

- Mode: mode(theta[j]) = (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.

### Value

`ddirichlet` gives the density and `rdirichlet` generates random deviates.

### See Also

`dbeta`, `dcat`, `dmvpolya`, `dmultinom`, and `TransitionMatrix`.

### Examples

    library(LaplacesDemon)
    x <- ddirichlet(c(.1,.3,.6), c(1,1,1))
    x <- rdirichlet(10, c(1,1,1))

[Package LaplacesDemon version 16.1.1 Index]