This function draws from a multivariate normal distribution.
rmvnorm_cpp(mean, Sigma, log = FALSE)
A column vector of length p
, the random draw.
A numeric
, the mean vector of length p
.
A matrix
, the covariance matrix of dimension p
x p
.
A logical
, if TRUE
the draw is taken from the log-normal
distribution.
By default, log = FALSE
.
The function builds upon the following fact: If \(\epsilon = (\epsilon_1,\dots,\epsilon_p)\), where each \(\epsilon_i\) is drawn independently from a standard normal distribution, then \(\mu + L\epsilon\) is a draw from the \(p\)-variate normal distribution \(N(\mu,\Sigma)\), where \(L\) is the lower triangular factor of the Choleski decomposition of \(\Sigma\).
This function performs no input checks. See rmvnorm
for the version with input checks.