R/rmvnorm.R

#' @importFrom stats rnorm

rmvnorm <- function (n = 1, mean, var) {
  p <- length(mean)
  ##  if (!all(dim(var)==c(p,p)))
  ##    pStop_("length of ",sQuote("mean")," must equal the dimension of the square matrix ",sQuote("var"),".")
  cf <- t(chol(var))
  matrix(mean,p,n)+cf%*%matrix(rnorm(p*n),p,n)
}
kingaa/ouch documentation built on April 3, 2024, 1:34 a.m.