rdirichlet | R Documentation |
This function simulates a sample from
a Dirichlet distribution on the k
dimensional simplex with
arbitrary parameters.
The simulation is based on a renormalised vector of gamma variates.
rdirichlet(n = 1, par = rep(1, 2))
n |
number of simulations |
par |
parameters of the Dirichlet distribution, whose length determines
the value of |
Surprisingly, there is no default Dirichlet distribution generator in the R base
packages like MASS
or stats
. This function can be used in full
generality, apart from the book (Chapter 6).
returns a (n,k)
matrix of Dirichlet simulations
apply(rdirichlet(10,rep(3,5)),2,mean)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.