R/I_rmvn.R

Defines functions .rmvn

#
# Simulate multivariate normal variable. Each ROW is a random vector

.rmvn <- function(n, mu, sigma, isChol = FALSE)
{
  d <- length(mu)
  
  if(isChol) cholFact <- t(sigma) else cholFact <- t( chol(sigma) )

  return( t( mu + cholFact %*% matrix(rnorm(n*d), d, n) ) ) 
  
}
  

Try the synlik package in your browser

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

synlik documentation built on March 7, 2023, 8:39 p.m.