Learn R Programming

ForestFit (version 2.4.3)

rmvnorm: Generating from multivariate normal distribution with location vector \(\bold{\mu}\) and covariance matrix \(\Sigma_{d \times d}\).

Description

Using the well-recognized Cholesky decomposition, this function simulates from the density function of a \(d\)-dimensional random vector \(\bold{Y}=(Y_1,\cdots,Y_d)^{T}\) following a normal distribution with mean vector \(\bold{\mu}\) and covariance matrix \(\Sigma_{d \times d}\) is $$ f_{\bold{Y}}(\bold{y})=\frac{1}{(2 \pi)^{\frac{d}{2}}\vert \Sigma\vert ^{-\frac{1}{2} } } \exp\biggl\{-\frac{(\bold{y}-\bold{\mu})^t\Sigma^{-1}(\bold{y}-\bold{\mu})}{2}\bigg\}, $$

Usage

rmvnorm(n, Mu, Sigma)

Value

an \(n \times d\) matrix of realizations from multivariate normal distribution with mean vector \(\bold{\mu}\) and covariance matrix \(\Sigma_{d \times d}\).

Arguments

n

number of realizations.

Mu

location vector.

Sigma

covariance (dispersion) matrix.

Author

Mahdi Teimouri

Examples

Run this code
# \donttest{
      n <- 100
    Mu  <- rep(0, 2)
 Sigma  <- matrix( c( 2, 0.50, 0.50, 2 ), nrow = 2, ncol = 2 )
 rmvnorm(n, Mu, Sigma)
# }

Run the code above in your browser using DataLab