rdirichlet: The Dirichlet Random Vector Generating Function

Description Usage Arguments Details Value Author(s) Source References See Also Examples

Description

The function to generate random vectors from the Dirichlet distribution.

Usage

1
 rdirichlet(n, shape)

Arguments

n

Number of Dirichlet random vectors to generate. If length(n) > 1, the length is taken to be the number required.

shape

Vector with length(shape) >= 2 containing positive shape parameters of the Dirichlet distribution. If length(shape) = 2, it reduces to the beta generating function.

Details

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

A k-variate Dirichlet random vector (x[1],…,x[k]) has the joint probability density function

Γ(α[1]+…+α[k+1])(Γ(α[1])…Γ(α[k+1])) x[1]^(α[1]-1)… x_k^(α[k]-1)(1-∑_{i=1}^k x[i])^(α[k+1]-1),

where x[i] ≥ 0 for all i = 1, …, k, ∑_{i=1}^k x[i] ≤ 1, and α[1], …, α[k+1] are positive shape parameters.

rdirichlet generates the Dirichlet random vector by utilizing the transformation method based on beta variates and three guidelines introduced by Hung et al. (2011). The three guidelines include: how to choose the fastest beta generation algorithm, how to best re-order the shape parameters, and how to reduce the amount of arithmetic operations.

Value

rdirichlet() returns a matrix with n rows, each containing a single Dirichlet random vector.

Author(s)

Ching-Wei Cheng <aks43725@gmail.com>,
Ying-Chao Hung <hungy@nccu.edu.tw>,
Narayanaswamy Balakrishnan <bala@univmail.cis.mcmaster.ca>

Source

rdirichlet uses a C translation of

Y. C. Hung and N. Balakrishnan and C. W. Cheng (2011), Evaluation of algorithms for generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81, 445–459.

References

Y. C. Hung and N. Balakrishnan and C. W. Cheng (2011), Evaluation of algorithms for generating Dirichlet random vectors, Journal of Statistical Computation and Simulation, 81, 445–459.

See Also

rdirichlet in package MCMCpack.
rdirichlet in package gtools.

Examples

1
2
library(rBeta2009)
rdirichlet(10, c(1.5, 0.7, 5.2, 3.4))


Search within the rBeta2009 package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.