G01LBF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G01LBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

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

SUBROUTINE G01LBF ( ILOG, K, N, X, LDX, XMU, IULD, SIG, LDSIG, PDF, RANK, IFAIL)
INTEGER  ILOG, K, N, LDX, IULD, LDSIG, RANK, IFAIL
REAL (KIND=nag_wp)  X(LDX,*), XMU(N), SIG(LDSIG,*), PDF(K)

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  Parameters

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 parameter you should refer to Section 3.3 in the Essential Introduction 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 parameter, 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.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction 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)


G01LBF (PDF version)
G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015