Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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

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

splus2R

Supplemental S-PLUS Functionality in R

v1.3-3
GPL-2
Authors
William Constantine [aut], Tim Hesterberg [aut], Knut Wittkowski [ctb], Tingting Song [ctb], Bill Dunlap [ctb], Stephen Kaluzny [ctb, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.