Learn R Programming

monomvn (version 1.2)

randmvn: 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

Value

  • The return value is a list with the following components:
  • murandomly generated mean vector of length d
  • Srandomly generated covariance matrix with d rows and d columns
  • xif 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

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)

See Also

rwish, rmvnorm, rmono

Examples

Run this code
randmvn(5, 3)

Run the code above in your browser using DataLab