rdirichlet(n, shape)
length(n) > 1
,
the length is taken to be the number required.length(shape) >= 2
containing positive shape parameters of
the Dirichlet distribution. If length(shape) = 2
, it reduces to the beta
generating function.rdirichlet()
returns a matrix with n
rows, each containing a single Dirichlet
random vector.
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.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.
rdirichlet
in package MCMCpack.
rdirichlet
in package gtools.
library(rBeta2009)
rdirichlet(10, c(1.5, 0.7, 5.2, 3.4))
Run the code above in your browser using DataLab