R/logsumexp.R

Defines functions logsumexp

Documented in logsumexp

#' logsumexp
#'
#' Compute log(sum(exp(X))) while avoiding numerical underflow
#'
#' @param X: Vector

logsumexp = function(X){
  a = max(X)
  y = a + log(sum(exp(X-a)))
  return(y)
}
jtm508/bayestraj documentation built on July 7, 2018, 7:58 p.m.