# rdirichlet: The Dirichlet Random Vector Generating Function In rBeta2009: The Beta Random Number and Dirichlet Random Vector Generating Functions

## 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 <[email protected]>,
Ying-Chao Hung <[email protected]>,
Narayanaswamy Balakrishnan <[email protected]>

## 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.

`rdirichlet` in package MCMCpack.
`rdirichlet` in package gtools.
 ```1 2``` ```library(rBeta2009) rdirichlet(10, c(1.5, 0.7, 5.2, 3.4)) ```