hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_stat_pdf_multi_normal_vector (g01lb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

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

Syntax

[pdf, rank, ifail] = g01lb(ilog, k, x, xmu, iuld, sig, 'n', n)
[pdf, rank, ifail] = nag_stat_pdf_multi_normal_vector(ilog, k, x, xmu, iuld, sig, 'n', n)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 25: k was made optional

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

References

None.

Parameters

Compulsory Input Parameters

1:     ilog int64int32nag_int scalar
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 int64int32nag_int scalar
k, the number of points the PDF is to be evaluated at.
Constraint: k0.
3:     xldx: – double array
The first dimension of the array x must be at least n.
The second dimension of the array x must be at least k.
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.
4:     xmun – double array
μ, the mean vector of the multivariate Normal distribution.
5:     iuld int64int32nag_int scalar
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.
6:     sigldsig: – double array
The first dimension, ldsig, of the array sig must satisfy
  • if iuld=3, ldsig1;
  • otherwise ldsign.
The second dimension of the array sig must be at least n.
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

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array x and the dimension of the array xmu and the first dimension of the array sig and the second dimension of the array sig. (An error is raised if these dimensions are not equal.)
n, the number of dimensions.
Constraint: n2.

Output Parameters

1:     pdfk – double array
fX:μ,Σ or logfX:μ,Σ depending on the value of ilog.
2:     rank int64int32nag_int scalar
r, rank of Σ.
3:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=11
Constraint: ilog=0 or 1.
   ifail=21
Constraint: k0.
   ifail=31
Constraint: n2.
   ifail=51
Constraint: ldxn.
   ifail=71
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
Constraint: if iuld=3, ldsig1.
   ifail=92
Constraint: if iuld3, ldsign.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Not applicable.

Further Comments

None.

Example

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


fprintf('g01lb example results\n\n');

ilog = int64(0);
k    = int64(2);
iuld = int64(1);
xmu  = [0.1; 0.2; 0.3; 0.4];
sig  = [4.16,  0,     0,     0;
       -3.12,  5.03,  0,     0;
        0.56, -0.83,  0.76,  0;
       -0.10,  1.18,  0.34,  1.18];
x    = [1, 1;
        1, 2;
        1, 3;
        1, 4];

[pdf, rnk, ifail] = g01lb(ilog, x, xmu, iuld, sig);

fprintf('\nRank of the covariance matrix: %d\n', rnk);
if ilog == 1
  fprintf('     log(PDF)                  X\n');
else
  fprintf('       PDF                     X\n');
end
for i=1:k
  fprintf('%13.4e %8.4f %8.4f %8.4f %8.4f\n', pdf(i), x(:, i));
end


g01lb example results


Rank of the covariance matrix: 4
       PDF                     X
   3.0307e-03   1.0000   1.0000   1.0000   1.0000
   4.5232e-06   1.0000   2.0000   3.0000   4.0000

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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