rmvnorm: Simulate from a Multivariate Normal Distribution

View source: R/rmvnorm.R

rmvnormR Documentation

Simulate from a Multivariate Normal Distribution

Description

Simulate from a Multivariate Normal Distribution

Usage

rmvnorm(n = 1, mu, v, method = "eigen")

Arguments

n

the number of samples required

mu

a vector giving the mean of the random variables

v

the covariance matrix of the random variables

method

The method used to decompose v. Valid options are "chol", "eigen", or "svd".

Value

An m \times n where n is the length of mu.

Examples

v = matrix(c(10,3,3,2), 2, 2)
y = rmvnorm(n = 4000, 1:2, v)
# should be close to 1:2
# rowMeans(y)
# should be close to v
# var(t(y))

jfrench/bayesutils documentation built on April 10, 2023, 6:28 p.m.