R/rdirichlet.R

Defines functions rdirichlet

Documented in rdirichlet

#' Generate a random sample from a Dirichlet distribution
#'
#'
#' @param gamma Prior concentration vector of length K
#' @return a vector of length K that is a random sample from a Dirichlet distribution
#' @export
rdirichlet = function(gamma){
  Y = sapply(gamma,function(j)rgamma(1,j,1))
  
  return(Y/sum(Y))
}

Try the fabPrediction package in your browser

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

fabPrediction documentation built on May 29, 2024, 7:05 a.m.