This function draws from a multivariate normal distribution.
rmvnorm(mu, Sigma)
Arguments
mu: The mean vector of length n.
Sigma: The covariance matrix of dimension n x n.
Returns
A numeric vector of length n.
Details
The function builds upon the following fact: If ϵ=(ϵ1,…,ϵn), where each ϵi is drawn independently from a standard normal distribution, then μ+Lϵ is a draw from the multivariate normal distribution N(μ,Σ), where L is the lower triangular factor of the Choleski decomposition of Σ.
Examples
mu <- c(0,0)Sigma <- diag(2)rmvnorm(mu = mu, Sigma = Sigma)