rmvnorm {splus2R}R Documentation

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 is a covariance matrix. If sd is a matrix then one row is used for each observation.

Value

random sample ( rmvnorm) for the multivariate normal distribution.

See Also

rnorm,set.seed.

Examples

## 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))

[Package splus2R version 1.3-5 Index]