Learn R Programming

Boom (version 0.9.15)

rmvn: Multivariate Normal Simulation

Description

Simulate draws from the multivariate normal distribution.

Usage

rmvn(n = 1, mu, sigma = diag(rep(1., length(mu))))

Value

If n == 1 the return value is a vector. Otherwise it is a matrix with n rows and length(mu) columns.

Arguments

n

The desired number of draws.

mu

The mean of the distribution. A vector.

sigma

The variance matrix of the distribution. A matrix.

Author

Steven L. Scott steve.the.bayesian@gmail.com

Details

Note that mu and sigma are the same for all n draws. This function cannot handle separate parameters for each draw the way rnorm and similar functions for scalar random variables can.

Examples

Run this code
y1 <- rnorm(1, 1:3)
## y1 is a vector
y2 <- rnorm(10, 1:3)
## y2 is a matrix

Run the code above in your browser using DataLab