# Mvnorm: Multivariate Normal Density and Random Deviates In mvtnorm: Multivariate Normal and t Distributions

## Description

These functions provide the density function and a random number generator for the multivariate normal distribution with mean equal to `mean` and covariance matrix `sigma`.

## Usage

 ```1 2 3``` ```dmvnorm(x, mean = rep(0, p), sigma = diag(p), log = FALSE, checkSymmetry = TRUE) rmvnorm(n, mean = rep(0, nrow(sigma)), sigma = diag(length(mean)), method=c("eigen", "svd", "chol"), pre0.9_9994 = FALSE, checkSymmetry = TRUE) ```

## Arguments

 `x` vector or matrix of quantiles. If `x` is a matrix, each row is taken to be a quantile. `n` number of observations. `mean` mean vector, default is `rep(0, length = ncol(x))`. `sigma` covariance matrix, default is `diag(ncol(x))`. `log` logical; if `TRUE`, densities d are given as log(d). `method` string specifying the matrix decomposition used to determine the matrix root of `sigma`. Possible methods are eigenvalue decomposition (`"eigen"`, default), singular value decomposition (`"svd"`), and Cholesky decomposition (`"chol"`). The Cholesky is typically fastest, not by much though. `pre0.9_9994` logical; if `FALSE`, the output produced in mvtnorm versions up to 0.9-9993 is reproduced. In 0.9-9994, the output is organized such that `rmvnorm(10,...)` has the same first ten rows as `rmvnorm(100, ...)` when called with the same seed. `checkSymmetry` logical; if `FALSE`, skip checking whether the covariance matrix is symmetric or not. This will speed up the computation but may cause unexpected outputs when ill-behaved `sigma` is provided. The default value is `TRUE`.

## Author(s)

Friedrich Leisch and Fabian Scheipl

`pmvnorm`, `rnorm`, `qmvnorm`

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```dmvnorm(x=c(0,0)) dmvnorm(x=c(0,0), mean=c(1,1)) sigma <- matrix(c(4,2,2,3), ncol=2) x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma) colMeans(x) var(x) x <- rmvnorm(n=500, mean=c(1,2), sigma=sigma, method="chol") colMeans(x) var(x) plot(x) ```

### Example output ``` 0.1591549
 0.05854983
 0.8462846 1.8995820
[,1]     [,2]
[1,] 3.781973 1.880966
[2,] 1.880966 2.959110
 1.030278 2.010795
[,1]     [,2]
[1,] 4.035400 2.023131
[2,] 2.023131 2.962861
```

mvtnorm documentation built on Oct. 8, 2021, 5:07 p.m.