R/rdirich.R

Defines functions rdirich

Documented in rdirich

########################### Random values from dirichlet distribution ###########################################
rdirich <- function(n,alphavec) {

 k <- length(alphavec)
 p <- matrix(rgamma(n*k,alphavec),n,k,byrow=T)
 sm <- matrix(apply(p,1,sum),n,k)
 return(p/sm)

}  

Try the lba package in your browser

Any scripts or data that you put into this service are public.

lba documentation built on Aug. 31, 2023, 1:08 a.m.