Last data update: 2014.03.03
|
R: Random generator for the multivariate normal distribution
Random generator for the multivariate normal distribution
Description
This function produces one random vector distributed from the multivariate normal distribution
N(mu,sig).
Usage
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
the fact that sig is a square matrix,
the compatibility of the dimensions of x , mu , sig
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
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
Results
|