R/dmvnorm.R

Defines functions dmvnorm

Documented in dmvnorm

#[export]
dmvnorm <- function(x, mu, sigma, logged = FALSE) {
  quat <-  - 0.5 * Rfast::mahala(x, mu, sigma)
  pow <- length(mu)/2
  con <- (2 * pi)^pow * sqrt( det(sigma) )
  if ( logged ) {
    den <- quat - log( con )
  } else  den <- exp(quat) / con
  den
}

Try the Rfast package in your browser

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

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.