Learn R Programming

splus2R (version 1.0-1)

rmvnorm: Multivariate Normal (Gaussian) Distribution

Description

Random generation for the multivariate normal (also called Gaussian) distribution.

Usage

rmvnorm(n, mean=rep(0,d), cov=diag(d), sd, rho, d=2)

Arguments

n
sample size -- number of random vectors of length d to return (as rows in a matrix).
cov
covariance or correlation matrix with d rows and columns.
d
dimension of the multivariate normal.
mean
vector of length d, or matrix with n rows and d columns.
rho
scalar, vector, or bdVector of length n, containing correlations for bivariate data. This is ignored if cov is supplied.
sd
vector of length d, or matrix with n rows and d columns, containing standard deviations. If supplied, the rows and columns of cov are multiplied by sd. In particular, if cov is a correlation matrix and sd is a vector of standard deviations, the result

Value

  • random sample ( rmvnorm) for the multivariate normal distribution.

concept

splus

See Also

anyMissing, as.rectangular, colIds, colMaxs, colMedians, colMins, colRanges, colStdevs, colVars, deparseText, ifelse1, is.numeric.atomic.vector, is.rectangular, is.missing, is.zero, lowerCase, oldUnclass, numCols, numRows, peaks, positions, rowIds, rowMaxs, stdev, subscript2d, upperCase, vecnorm, which.na.

Examples

Run this code
## 5 rows and 2 independent columns 
rmvnorm(5)

## 5 rows and 3 independent columns 
rmvnorm(5, mean=c(9,3,1))

## 2 columns, std. dev. 1, correlation .9 
rmvnorm(5, rho=.9)

## specify variable means and covariance matrix 
rmvnorm(5, mean=c(9,3), cov=matrix(c(4,1,1,2), 2))

Run the code above in your browser using DataLab