This function generates samples from a multivariate normal distribution
using the Cholesky decomposition method. It first computes the Cholesky
factorization of the covariance matrix, then generates standard normal
random variables, and finally transforms them to the desired multivariate
normal distribution.
# Generate 5 samples from a bivariate normal distribution with mean (0,0)# and covariance matrix [[1, 0.5], [0.5, 1]]set.seed(314159)
rmvnorm(5, c(0, 0), matrix(c(1, 0.5, 0.5, 1), nrow=2))