MVNorm function

The Multivariate Normal Distribution

The Multivariate Normal Distribution

Functions to compute the density of a multivariate normal distribution and to generate random realizations from such a distribution.

dMVNorm (x, mean, sigma, log = FALSE) rMVNorm (n, mean = rep(0, nrow(sigma)), sigma = diag(length(mean)), method=c("eigen", "svd", "chol"))

Arguments

  • x: Vector or matrix of quantiles. If x is a matrix, each row is taken to be a quantile.
  • n: Number of realizations.
  • mean: Mean vector, default is rep(0, length = ncol(x)).
  • sigma: Covariance matrix, default is diag(ncol(x)).
  • log: Logical; if TRUE, densities are log-transformed.
  • method: 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").

Returns

rMVNorm returns a vector of the same length as mean if n=1, or a matrix with each row being an independent realization otherwise.

Author(s)

The code for both functions is taken from similar functions written by Friedrich Leisch and Fabian Scheipl in R package mvtnorm. Audrey Q. Fu modified dMVNorm to use a different method to compute the matrix determinants.

Examples

## Not run: x <- rMVNorm (10, mean=rep(0,3), method="svd") dMVNorm (x, mean=rep(0,3), log=TRUE) ## End(Not run)
  • Maintainer: Audrey Q. Fu
  • License: GPL (>= 2)
  • Last published: 2023-09-07

Useful links