Learn R Programming

mcsm (version 1.0)

dmunorm: Density function of the multivariate normal distribution

Description

This function computes the density of the multivariate normal distribution $N(mu,sig)$ in either natural or logarithmic scales.

Usage

dmunorm(x, mu, sig, log = FALSE)

Arguments

x
Running argument of the density
mu
Mean $mu$ of the normal distribution
sig
Covariance matrix $sig$ of the normal distribution
log
Boolean describing whether or not the output is in logarithmic scales

Value

This function returns a real number corresponding to the density in $x$ in either natural or logarithmic scales.

Warning

This function is fragile in that it does not test for
  1. the fact that sig is a square matrix,
  2. the compatibility of the dimensions of x, mu, sig
  3. the symmetry nor the invertibility of the matrix sig
It is therefore prone to fail if those conditions are not satified! If the package mvtnorm is installed, the function dmvnorm should be used instead.

References

Chapter 8 of EnteR Monte Carlo Statistical Methods

Examples

Run this code
dmunorm(c(1,2),c(1,2),diag(rep(1,2)))-1/(2*pi)
# Should be equal to zero!

Run the code above in your browser using DataLab