swh:1:snp:ffdd0a7d2c8ea15ad41d45b3b178f668bd942287
Raw File
Tip revision: 1c995ef374a8438306839bffe3c09b7c524aebdd authored by Derek Young on 28 April 2009, 07:56:28 UTC
version 0.4.0
Tip revision: 1c995ef
ldmult.R
###########################################################################
# log density function of multinomial count vector y with parameter theta #
###########################################################################

ldmult<-function(y,theta){
  if (any(is.nan(theta)) || any(theta==0)) {
#      stop ("The theta parameter cannot have a zero component.")
     out = -Inf
   }
   else {
     if (length(y)==length(theta)+1)
       theta=c(theta,1-sum(theta))
     out=lgamma(1+sum(y)) - sum(lgamma(1+y)) + sum(y*log(theta))
   }
   out
}


back to top