Learn R Programming

emdbook (version 1.3.2.1)

dmvnorm: Multivariate normal distribution density function

Description

Calculates the probability density function of the multivariate normal distribution

Usage

dmvnorm(x, mu, Sigma, log = FALSE, tol = 1e-06)

Arguments

x
a vector or matrix of multivariate observations
mu
a vector or matrix of mean values
Sigma
a square variance-covariance matrix
log
(logical) return log-likelihood?
tol
tolerance for positive definiteness

Value

  • vector of log-likelihoods

Details

uses naive linear algebra -- could probably use QR decomposition and/or crossprod.

See Also

mvrnorm (in MASS package), dmvnorm (in mvtnorm package)

Examples

Run this code
M = matrix(c(1,0.5,0.5,0.5,1,0.5,0.5,0.5,1),nrow=3)
dmvnorm(1:3,mu=1:3,Sigma=M,log=TRUE)
dmvnorm(matrix(1:6,nrow=2),mu=1:3,Sigma=M,log=TRUE)
dmvnorm(matrix(1:6,nrow=2),mu=matrix(1:6,nrow=2),Sigma=M,log=TRUE)

Run the code above in your browser using DataLab