NAG Library Function Document

nag_multi_normal_pdf_vector (g01lbc)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

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

2
Specification

#include <nag.h>
#include <nagg01.h>
void  nag_multi_normal_pdf_vector (Nag_Boolean ilog, Integer k, Integer n, const double x[], Integer pdx, const double xmu[], Nag_MatrixType iuld, const double sig[], Integer pdsig, double pdf[], Integer *rank, NagError *fail)

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.
nag_multi_normal_pdf_vector (g01lbc) evaluates the PDF at k points with a single call.

4
References

None.

5
Arguments

1:     ilog Nag_BooleanInput
On entry: the value of ilog determines whether the logarithmic value is returned in PDF.
ilog=Nag_FALSE
fX:μ,Σ, the probability density function is returned.
ilog=Nag_TRUE
logfX:μ,Σ, the logarithm of the probability density function is returned.
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:     x[dim] const doubleInput
Note: the dimension, dim, of the array x must be at least pdx×k.
Where Xi,j appears in this document, it refers to the array element x[j-1×pdx+i-1].
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 Xi,j.
5:     pdx IntegerInput
On entry: the stride separating matrix row elements in the array x.
Constraint: pdxn.
6:     xmu[n] const doubleInput
On entry: μ, the mean vector of the multivariate Normal distribution.
7:     iuld Nag_MatrixTypeInput
On entry: indicates the form of Σ and how it is stored in sig.
iuld=Nag_LowerMatrix
sig holds the lower triangular portion of Σ.
iuld=Nag_UpperMatrix
sig holds the upper triangular portion of Σ.
iuld=Nag_DiagonalMatrix
Σ is a diagonal matrix and sig only holds the diagonal elements.
iuld=Nag_LowerFactored
sig holds the lower Cholesky decomposition, L such that LLT=Σ.
iuld=Nag_UpperFactored
sig holds the upper Cholesky decomposition, U such that UTU=Σ.
Constraint: iuld=Nag_LowerMatrix, Nag_UpperMatrix, Nag_DiagonalMatrix, Nag_LowerFactored or Nag_UpperFactored.
8:     sig[dim] const doubleInput
Note: the dimension, dim, of the array sig must be at least pdsig×n.
Where SIGi,j appears in this document, it refers to the array element sig[j-1×pdsig+i-1].
On entry: information defining the variance-covariance matrix, Σ.
iuld=Nag_LowerMatrix or Nag_UpperMatrix
sig must hold the lower or upper portion of Σ, with Σij held in SIGi,j. The supplied variance-covariance matrix must be positive semidefinite.
iuld=Nag_DiagonalMatrix
Σ is a diagonal matrix and the ith diagonal element, Σii, must be held in SIG1,i
iuld=Nag_LowerFactored or Nag_UpperFactored
sig must hold L or U, the lower or upper Cholesky decomposition of Σ, with Lij or Uij held in SIGi,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:     pdsig IntegerInput
On entry: the stride separating matrix row elements in the array sig.
Constraints:
  • if iuld=Nag_DiagonalMatrix, pdsig1;
  • otherwise pdsign.
10:   pdf[k] doubleOutput
On exit: fX:μ,Σ or logfX:μ,Σ depending on the value of ilog.
11:   rank Integer *Output
On exit: r, rank of Σ.
12:   fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

6
Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_ARRAY_SIZE
On entry, pdsig=value.
Constraint: if iuld=Nag_DiagonalMatrix, pdsig1.
On entry, pdsig=value.
Constraint: if iuldNag_DiagonalMatrix, pdsign.
On entry, pdx=value and n=value.
Constraint: pdxn.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_DIAG_ELEMENTS
On entry, at least one diagonal element of Σ is less than or equal to 0.
NE_INT
On entry, k=value.
Constraint: k0.
On entry, n=value.
Constraint: n2.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_MAT_NOT_POS_DEF
On entry, Σ is not positive definite and eigenvalue decomposition failed.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_POS_SEM_DEF
On entry, Σ is not positive semidefinite.

7
Accuracy

Not applicable.

8
Parallelism and Performance

nag_multi_normal_pdf_vector (g01lbc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_multi_normal_pdf_vector (g01lbc) 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 function. 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 (g01lbce.c)

10.2
Program Data

Program Data (g01lbce.d)

10.3
Program Results

Program Results (g01lbce.r)

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