randmvn {monomvn}R Documentation

Randomly Generate a Multivariate Normal Distribution

Description

Randomly generate a mean vector and covariance matrix describing a multivariate normal (MVN) distribution, and then sample from it

Usage

randmvn(N, d)

Arguments

N number of samples to draw
d dimension of the MVN, i.e., the length of the mean vector and the number of rows/cols of the covariance matrix

Details

The components of the mean vector mu are iid from a standard normal distribution, and the covariance matrix S is drawn from an inverse–Wishart distribution with degrees of freedom d + 2 and mean (centering matrix) diag(d)

Value

The return value is a list with the following components:

mu randomly generated mean vector of length d
S randomly generated covariance matrix with d rows and d columns
x if N > 0 then x is an N by d matrix of N samples from the MVN with mean vector mu and covariance matrix S; otherwise when N = 0 this component is not included

Note

requires the rmvnorm function of the mvtnorm package

Author(s)

Robert B. Gramacy bobby@statslab.cam.ac.uk

See Also

rwish, rmvnorm, rmono

Examples

randmvn(5, 3)

[Package monomvn version 1.1-4 Index]