Learn R Programming

oeli (version 0.5.2)

rmvnorm: Draw from multivariate normal distribution

Description

This function draws from a multivariate normal distribution.

Usage

rmvnorm(n = 1, mean, Sigma, log = FALSE)

Value

If n = 1 a vector of length p, else a matrix of dimension n times p with samples as rows.

Arguments

n

An integer, the number of samples.

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.

Examples

Run this code
mean <- c(0, 0)
Sigma <- diag(2)
rmvnorm(n = 3, mean = mean, Sigma = Sigma)
rmvnorm(mean = mean, Sigma = Sigma, log = TRUE)

Run the code above in your browser using DataLab