Learn R Programming

oeli (version 0.5.2)

rmvnorm_cpp: Draw from multivariate normal distribution

Description

This function draws from a multivariate normal distribution.

Usage

rmvnorm_cpp(mean, Sigma, log = FALSE)

Value

A column vector of length p, the random draw.

Arguments

mean

A numeric, the mean vector of length p.

Sigma

A matrix, the covariance matrix of dimension p x p.

log

A logical, if TRUE the draw is taken from the log-normal distribution. By default, log = FALSE.

Details

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.