rmunorm: Random generator for the multivariate normal distribution

Description Usage Arguments Value Warning Author(s) References See Also Examples

View source: R/rmunorm.R

Description

This function produces one random vector distributed from the multivariate normal distribution N(mu,sig).

Usage

1
rmunorm(mu, sig)

Arguments

mu

Mean mu of the normal distribution

sig

Covariance matrix sig of the normal distribution

Value

This function returns a real vector of the same dimension as mu.

Warning

Similar to dmunorm, this function is fragile in that it does not test for

  1. the fact that sig is a square matrix,

  2. the compatibility of the dimensions of x, mu, sig

  3. the symmetry nor the invertibility of the matrix sig

It is therefore prone to fail if those conditions are not satified! If the package bayesm can be installed, rmvnorm is to be prefered to rmunorm.

Author(s)

Christian P. Robert and George Casella

References

Chapter 8 of EnteR Monte Carlo Statistical Methods

See Also

rnorm,dmunorm,rmvnorm(bayesm)

Examples

1
2
3
test=NULL
for (t in 1:10^4) test=rbind(test,rmunorm(rep(1,2),matrix(c(1,-2,-2,10),ncol=2)))
cor(test[,1],test[,2])*sqrt(10)  # should be close to -2

mcsm documentation built on May 2, 2019, 10:16 a.m.

Related to rmunorm in mcsm...