rdirichlet {mcsm} | R Documentation |
This is a random generator for Dirichlet D(a1,...,ad) distributions, based on the normalisation of Gamma gamma(ai) random variables.
rdirichlet(n, shape)
n |
Number of generations requested |
shape |
Vector of ai's |
A (n,length(shape)) matrix, with one simulated vector per row.
Christian P. Robert and George Casella
Used in Chapter 7 EnteR Monte Carlo Statistical Methods
rgamma
A=rdirichlet(10^3,rep(.5,5)) hist(A[,1],fre=FALSE,col="grey",nclass=123,xlim=c(0,1), main="",xlab=expression(p[1])) curve(dbeta(x,.5,4*.5),add=TRUE,col="sienna",lwd=2)