R/dirichletrnd.R

dirichletrnd <- function(a, n) {
  
  out <- matrix(nrow = n, ncol = length(a))
  
  for (i in 1:n) {
    y <- rgamma(length(a), a, 1)
    out[i, ] <- y / sum(y)
  }
  
  return(out)
  
}
Laurae2/LauraeCE documentation built on May 24, 2019, 6:19 p.m.