R/rmvnorm.R

rmvnorm <- function (n = 1, mean, var) {
  p <- length(mean)
  if (!all(dim(var)==c(p,p)))
    stop("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)
}

Try the ouch package in your browser

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

ouch documentation built on May 2, 2019, 6:53 p.m.