rdirichlet {gtools} | R Documentation |
Functions to compute the density of or generate random deviates from the Dirichlet distribution.
rdirichlet(n, alpha) ddirichlet(x, alpha)
x |
A vector containing a single random deviate or matrix containg one random deviate per row. |
n |
Number of random vectors to generate. |
alpha |
Vector or (for ddirichlet ) matrix containing shape
parameters. |
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.
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.
Code original posted by Ben Bolker to R-News on Fri Dec 15 2000. See http://www.r-project.org/nocvs/mail/r-help/2000/3865.html. Ben attributed the code to Ian Wilson i.wilson@maths.abdn.ac.uk. Subsequent modifications by Gregory R. Warnes greg@random-technologies-llc.com.
x <- rdirichlet(20, c(1,1,1) ) ddirichlet(x, c(1,1,1) )