Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

dirichlet-distribution

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

(gamma(sum(nu)) / prod(gamma(nu))) prod(pi^(nu - 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)

References

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


Boom

Bayesian Object Oriented Modeling

v0.9.7
LGPL-2.1 | file LICENSE
Authors
Steven L. Scott is the sole author and creator of the BOOM project. Some code in the BOOM libraries has been modified from other open source projects. These include Cephes (obtained from Netlib, written by Stephen L. Moshier), NEWUOA (M.J.D Powell, obtained from Powell's web site), and a modified version of the R math libraries (R core development team). Original copyright notices have been maintained in all source files. In these cases, copyright claimed by Steven L. Scott is limited to modifications made to the original code. Google claims copyright for code written while Steven L. Scott was employed at Google from 2008 - 2018, but BOOM is not an officially supported Google project.
Initial release
2021-02-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.