MCMCpack (version 1.7-0)

Dirichlet: The Dirichlet Distribution

Description

Density function and random generation from the Dirichlet distribution.

Usage

ddirichlet(x, alpha)

rdirichlet(n, alpha)

Value

ddirichlet gives the density. rdirichlet returns a matrix with n rows, each containing a single Dirichlet random deviate.

Arguments

x

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

alpha

Vector of shape parameters, or matrix of shape parameters corresponding to the number of draw.

n

Number of random vectors to generate.

Author

Code is taken from Greg's Miscellaneous Functions (gregmisc). His code was based on code posted by Ben Bolker to R-News on 15 Dec 2000.

Details

The Dirichlet distribution is the multidimensional generalization of the beta distribution.

See Also

Examples

Run this code

  density <- ddirichlet(c(.1,.2,.7), c(1,1,1))
  draws <- rdirichlet(20, c(1,1,1) )

Run the code above in your browser using DataLab