# rmvnorm: Multivariate Normal (Gaussian) Distribution In splus2R: Supplemental S-PLUS Functionality in R

## Description

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

## Usage

 `1` ```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.

`rnorm`,`set.seed`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11``` ```## 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)) ```

### Example output

```           [,1]       [,2]
[1,]  1.3861034  0.3364890
[2,]  1.2502044 -0.5277405
[3,] -0.2697167  0.2074887
[4,] -1.0157893  0.2254733
[5,]  1.9201236  1.3153500
[,1]      [,2]       [,3]
[1,]  8.934760 0.7432428  1.9202167
[2,]  8.737505 3.2633650  1.2534644
[3,] 11.342857 3.8251114 -2.5012796
[4,]  8.814599 3.2251518  0.7740151
[5,]  8.305913 1.3960000  0.6085833
[,1]       [,2]
[1,]  1.3926143  1.0978886
[2,] -2.4311053 -2.1168523
[3,]  0.2731813  0.3657502
[4,] -0.1139043 -0.1088794
[5,] -0.6964237 -0.6535508
[,1]     [,2]
[1,]  9.915539 2.773005
[2,] 11.187863 2.184646
[3,]  8.763142 5.338998
[4,]  7.292369 2.359028
[5,]  7.880654 4.348776
```

splus2R documentation built on Jan. 30, 2021, 9:05 a.m.