R/lmgamma.R

Defines functions lmgamma

Documented in lmgamma

lmgamma <- function(y, dimension) {
  ## Log of the multivariate gamma distribution of order 'dimension'.
  ## This function appears as part of the normalizing constant for the
  ## Wishart distribution.
  stopifnot(is.numeric(dimension),
            length(dimension) == 1,
            dimension == as.integer(dimension),
            dimension >= 1)
  stopifnot(is.numeric(y), length(y) == 1)
  j <- 1:dimension
  normalizing.constant <- (dimension * (dimension - 1) / 4) * log(pi)
  ans <- sum(lgamma(y + (1 - j) / 2))
  return(ans + normalizing.constant)
}

Try the Boom package in your browser

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

Boom documentation built on Nov. 10, 2022, 5:56 p.m.