NAG FL Interface
g01lbf (pdf_​multi_​normal_​vector)

Settings help

FL Name Style:


FL Specification Language:


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 <nag.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)
The routine may be called by the names g01lbf or nagf_stat_pdf_multi_normal_vector.

3 Description

The probability density function, f(X:μ,Σ) of an n-dimensional multivariate Normal distribution with mean vector μ and n×n variance-covariance matrix Σ, is given by
f(X:μ,Σ) = ( (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
f(X:μ,Σ) = ( (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 Integer Input
On entry: the value of ilog determines whether the logarithmic value is returned in PDF.
ilog=0
f(X:μ,Σ), the probability density function is returned.
ilog=1
log(f(X:μ,Σ)), the logarithm of the probability density function is returned.
Constraint: ilog=0 or 1.
2: k Integer Input
On entry: k, the number of points the PDF is to be evaluated at.
Constraint: k0.
3: n Integer Input
On entry: n, the number of dimensions.
Constraint: n2.
4: x(ldx,*) Real (Kind=nag_wp) array Input
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 x(i,j).
5: ldx Integer Input
On entry: the first dimension of the array x as declared in the (sub)program from which g01lbf is called.
Constraint: ldxn.
6: xmu(n) Real (Kind=nag_wp) array Input
On entry: μ, the mean vector of the multivariate Normal distribution.
7: iuld Integer Input
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: sig(ldsig,*) Real (Kind=nag_wp) array Input
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 sig(i,j). 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 sig(1,i)
iuld=4 or 5
sig must hold L or U, the lower or upper Cholesky decomposition of Σ, with Lij or Uij held in sig(i,j), 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 Integer Input
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: pdf(k) Real (Kind=nag_wp) array Output
On exit: f(X:μ,Σ) or log(f(X:μ,Σ)) depending on the value of ilog.
11: rank Integer Output
On exit: r, rank of Σ.
12: ifail Integer Input/Output
On entry: ifail must be set to 0, -1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of -1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value -1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. 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 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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)