Density and random generation for the Dirichlet distribution.
ddirichlet(probabilities, nu, logscale = FALSE)
rdirichlet(n, nu)ddirichlet returns a vector of density values, with one
entry per row in probabilities. rdirichlet returns a
matrix (if n > 1) or a vector (if n==1) containing the
draws from the Dirichlet distribution with the specified parameters.
A vector representing a discrete probability distribution, or a matrix where each row is a discrete probability distribution. Zero probabilities are not allowed.
The parameters of the Dirichlet distribution. This can be a
vector of positive numbers, interpretable as prior counts, of length
matching the dimension of probabilities. If probabilities is
a matrix (or if n > 1) then nu can also be a matrix of
the same dimension, in which case each row of nu is used to
evaluate the corresponding row of probabilities.
Logical. If TRUE then return the density on the log scale. Otherwise return the density on the raw scale.
The number of desired draws.
Steven L. Scott steve.the.bayesian@gmail.com
The Dirichlet distribution is a generalization of the beta distribution. Whereas beta distribution is a model for probabilities, the Dirichlet distribution is a model for discrete distributions with several possible outcome values.
Let \(\pi\) denote a discrete probability distribution (a vector of positive numbers summing to 1), and let \(\nu\) be a vector of positive numbers (the parameters of the Dirichlet distribution), which can be thought of as prior counts. Then the density of the Dirichlet distribution can be written
$$f(\pi) = \frac{\Gamma(\sum_i\nu_i)}{\prod_i \Gamma(\nu_i)} \prod_i \pi_i^{\nu_i-1}.$$
Gelman, Carlin, Stern, Rubin (2003), "Bayesian Data Analysis", Chapman and Hall.