NAG Library Routine Document

g01lbf (pdf_multi_normal_vector)

1
Purpose

g01lbf returns a number of values of the probability density function (PDF), or its logarithm, for the multivariate Normal (Gaussian) distribution.

2
Specification

Fortran Interface
Subroutine g01lbf ( ilog, k, n, x, ldx, xmu, iuld, sig, ldsig, pdf, rank, ifail)
Integer, Intent (In):: ilog, k, n, ldx, iuld, ldsig
Integer, Intent (Inout):: ifail
Integer, Intent (Out):: rank
Real (Kind=nag_wp), Intent (In):: x(ldx,*), xmu(n), sig(ldsig,*)
Real (Kind=nag_wp), Intent (Out):: pdf(k)
C Header Interface
#include <nagmk26.h>
void  g01lbf_ (const Integer *ilog, const Integer *k, const Integer *n, const double x[], const Integer *ldx, const double xmu[], const Integer *iuld, const double sig[], const Integer *ldsig, double pdf[], Integer *rank, Integer *ifail)

3
Description

The probability density function, fX:μ,Σ of an n-dimensional multivariate Normal distribution with mean vector μ and n by n variance-covariance matrix Σ, is given by
fX:μ,Σ = 2π n Σ -1/2 exp -12 X-μT Σ-1 X-μ .  
If the variance-covariance matrix, Σ, is not of full rank then the probability density function, is calculated as
fX:μ,Σ = 2π r pdet Σ -1/2 exp -12 X-μT Σ- X-μ  
where pdetΣ is the pseudo-determinant, Σ- a generalized inverse of Σ and r its rank.
g01lbf evaluates the PDF at k points with a single call.

4
References

None.

5
Arguments

1:     ilog – IntegerInput
On entry: the value of ilog determines whether the logarithmic value is returned in PDF.
ilog=0
fX:μ,Σ, the probability density function is returned.
ilog=1
logfX:μ,Σ, the logarithm of the probability density function is returned.
Constraint: ilog=0 or 1.
2:     k – IntegerInput
On entry: k, the number of points the PDF is to be evaluated at.
Constraint: k0.
3:     n – IntegerInput
On entry: n, the number of dimensions.
Constraint: n2.
4:     xldx* – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array x must be at least k.
On entry: X, the matrix of k points at which to evaluate the probability density function, with the ith dimension for the jth point held in xij.
5:     ldx – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g01lbf is called.
Constraint: ldxn.
6:     xmun – Real (Kind=nag_wp) arrayInput
On entry: μ, the mean vector of the multivariate Normal distribution.
7:     iuld – IntegerInput
On entry: indicates the form of Σ and how it is stored in sig.
iuld=1
sig holds the lower triangular portion of Σ.
iuld=2
sig holds the upper triangular portion of Σ.
iuld=3
Σ is a diagonal matrix and sig only holds the diagonal elements.
iuld=4
sig holds the lower Cholesky decomposition, L such that LLT=Σ.
iuld=5
sig holds the upper Cholesky decomposition, U such that UTU=Σ.
Constraint: iuld=1, 2, 3, 4 or 5.
8:     sigldsig* – Real (Kind=nag_wp) arrayInput
Note: the second dimension of the array sig must be at least n.
On entry: information defining the variance-covariance matrix, Σ.
iuld=1 or 2
sig must hold the lower or upper portion of Σ, with Σij held in sigij. The supplied variance-covariance matrix must be positive semidefinite.
iuld=3
Σ is a diagonal matrix and the ith diagonal element, Σii, must be held in sig1i
iuld=4 or 5
sig must hold L or U, the lower or upper Cholesky decomposition of Σ, with Lij or Uij held in sigij, depending on the value of iuld. No check is made that LLT or UTU is a valid variance-covariance matrix. The diagonal elements of the supplied L or U must be greater than zero
9:     ldsig – IntegerInput
On entry: the first dimension of the array sig as declared in the (sub)program from which g01lbf is called.
Constraints:
  • if iuld=3, ldsig1;
  • otherwise ldsign.
10:   pdfk – Real (Kind=nag_wp) arrayOutput
On exit: fX:μ,Σ or logfX:μ,Σ depending on the value of ilog.
11:   rank – IntegerOutput
On exit: r, rank of Σ.
12:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 or 1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=11
On entry, ilog=value.
Constraint: ilog=0 or 1.
ifail=21
On entry, k=value.
Constraint: k0.
ifail=31
On entry, n=value.
Constraint: n2.
ifail=51
On entry, ldx=value and n=value.
Constraint: ldxn.
ifail=71
On entry, iuld=value.
Constraint: iuld=1, 2, 3, 4 or 5.
ifail=81
On entry, Σ is not positive semidefinite.
ifail=82
On entry, at least one diagonal element of Σ is less than or equal to 0.
ifail=83
On entry, Σ is not positive definite and eigenvalue decomposition failed.
ifail=91
On entry, ldsig=value.
Constraint: if iuld=3, ldsig1.
ifail=92
On entry, ldsig=value.
Constraint: if iuld3, ldsign.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation for further information.

7
Accuracy

Not applicable.

8
Parallelism and Performance

g01lbf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g01lbf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9
Further Comments

None.

10
Example

This example prints the value of the multivariate Normal PDF at a number of different points.

10.1
Program Text

Program Text (g01lbfe.f90)

10.2
Program Data

Program Data (g01lbfe.d)

10.3
Program Results

Program Results (g01lbfe.r)