rmvnorm: Generate Random Multivariate Normal Draws via Pivoted...

View source: R/generic.R

rmvnormR Documentation

Generate Random Multivariate Normal Draws via Pivoted Cholesky

Description

An internal utility to simulate from a MVN distribution. By using a pivoted Cholesky decomposition, the function can handle semi-definite covariance matrices by effectively reducing the dimensionality to the numerical rank of the matrix.

Usage

rmvnorm(n, mu, Sig)

Arguments

n

Integer; the number of samples to generate.

mu

Numeric vector; the mean vector of length p.

Sig

Numeric matrix; the p x p covariance matrix.

Details

The function extracts the pivoting index and the numerical rank from the result of chol(Sig, pivot = TRUE). It then generates independent standard normal draws of dimension r (the rank) and transforms them using the Cholesky factor to match the target covariance and mean.

Value

A matrix of dimension n x p where each row is a random draw from the specified MVN distribution.


evgam documentation built on Sept. 3, 2026, 5:09 p.m.