dirichlet-distribution {Boom}R Documentation

The Dirichlet Distribution

Description

Density and random generation for the Dirichlet distribution.

Usage

ddirichlet(probabilities, nu, logscale = FALSE)
rdirichlet(n, nu)

Arguments

probabilities

A vector representing a discrete probability distribution, or a matrix where each row is a discrete probability distribution. Zero probabilities are not allowed.

nu

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.

logscale

Logical. If TRUE then return the density on the log scale. Otherwise return the density on the raw scale.

n

The number of desired draws.

Details

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

Value

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.

Author(s)

Steven L. Scott steve.the.bayesian@gmail.com

References

Gelman, Carlin, Stern, Rubin (2003), "Bayesian Data Analysis", Chapman and Hall.


[Package Boom version 0.9.15 Index]