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

dirichlet

Functions for the Dirichlet Distribution


Description

Functions to compute the density of or generate random deviates from the Dirichlet distribution.

Usage

rdirichlet(n, alpha)
ddirichlet(x, alpha)

Arguments

x

A vector containing a single random deviate or matrix containing one random deviate per row.

n

Number of random vectors to generate.

alpha

Vector or (for ddirichlet) matrix containing shape parameters.

Details

The Dirichlet distribution is the multidimensional generalization of the beta distribution. It is the canonical Bayesian distribution for the parameter estimates of a multinomial distribution.

Value

ddirichlet returns a vector containing the Dirichlet density for the corresponding rows of x.

rdirichlet returns a matrix with n rows, each containing a single Dirichlet random deviate.

Author(s)

Code original posted by Ben Bolker to R-News on Fri Dec 15 2000. See https://stat.ethz.ch/pipermail/r-help/2000-December/009561.html. Ben attributed the code to Ian Wilson i.wilson@maths.abdn.ac.uk. Subsequent modifications by Gregory R. Warnes greg@warnes.net.

See Also

Examples

x <- rdirichlet(20, c(1,1,1) )

  ddirichlet(x, c(1,1,1) )

gtools

Various R Programming Tools

v3.8.2
GPL-2
Authors
Gregory R. Warnes, Ben Bolker, and Thomas Lumley
Initial release
2020-03-23

We don't support your browser anymore

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