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)

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)

Description

The probability density function, f(X : μ,Σ)f(X:μ,Σ) of an nn-dimensional multivariate Normal distribution with mean vector μμ and nn by nn variance-covariance matrix ΣΣ, is given by
f(X : μ,Σ) = ((2π)n|Σ|)1 / 2 exp((1/2)(Xμ)TΣ1(Xμ)) .
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π)rpdet(Σ))1 / 2 exp((1/2)(Xμ)TΣ(Xμ))
f(X:μ,Σ) = ( (2π) r pdet( Σ ) ) -1/2 exp( -12 (X-μ)T Σ- (X-μ) )
where pdet(Σ)pdet(Σ) is the pseudo-determinant, ΣΣ- a generalized inverse of ΣΣ and rr its rank.
nag_stat_pdf_multi_normal_vector (g01lb) evaluates the PDF at kk 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 = 0ilog=0
f(X : μ,Σ)f(X:μ,Σ), the probability density function is returned.
ilog = 1ilog=1
log(f(X : μ,Σ))log(f(X:μ,Σ)), the logarithm of the probability density function is returned.
Constraint: ilog = 0ilog=0 or 11.
2:     k – int64int32nag_int scalar
kk, the number of points the PDF is to be evaluated at.
Constraint: k0k0.
3:     x(ldx, : :) – double array
The first dimension of the array x must be at least nn
The second dimension of the array must be at least kk
XX, the matrix of kk points at which to evaluate the probability density function, with the iith dimension for the jjth point held in x(i,j)xij.
4:     xmu(n) – double array
n, the dimension of the array, must satisfy the constraint n2n2.
μμ, 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 = 1iuld=1
sig holds the lower triangular portion of ΣΣ.
iuld = 2iuld=2
sig holds the upper triangular portion of ΣΣ.
iuld = 3iuld=3
ΣΣ is a diagonal matrix and sig only holds the diagonal elements.
iuld = 4iuld=4
sig holds the lower Cholesky decomposition, LL such that LLT = ΣLLT=Σ.
iuld = 5iuld=5
sig holds the upper Cholesky decomposition, UU such that UTU = ΣUTU=Σ.
Constraint: iuld = 1iuld=1, 22, 33, 44 or 55.
6:     sig(ldsig, : :) – double array
The first dimension, ldsig, of the array sig must satisfy
  • if iuld = 3iuld=3, ldsig1ldsig1;
  • otherwise ldsignldsign.
The second dimension of the array must be at least nn
Information defining the variance-covariance matrix, ΣΣ.
iuld = 1iuld=1 or 22
sig must hold the lower or upper portion of ΣΣ, with ΣijΣij held in sig(i,j)sigij. The supplied variance-covariance matrix must be positive semidefinite.
iuld = 3iuld=3
ΣΣ is a diagonal matrix and the iith diagonal element, ΣiiΣii, must be held in sig(1,i)sig1i
iuld = 4iuld=4 or 55
sig must hold LL or UU, the lower or upper Cholesky decomposition of ΣΣ, with LijLij or UijUij held in sig(i,j)sigij, depending on the value of iuld. No check is made that LLTLLT or UTUUTU is a valid variance-covariance matrix. The diagonal elements of the supplied LL or UU 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.)
nn, the number of dimensions.
Constraint: n2n2.

Input Parameters Omitted from the MATLAB Interface

ldx ldsig

Output Parameters

1:     pdf(kk) – double array
f(X : μ,Σ)f(X:μ,Σ) or log(f(X : μ,Σ))log(f(X:μ,Σ)) depending on the value of ilog.
2:     rank – int64int32nag_int scalar
rr, rank of ΣΣ.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 11ifail=11
On entry, ilog = _ilog=_.
Constraint: ilog = 0ilog=0 or 11.
  ifail = 21ifail=21
Constraint: k0k0.
  ifail = 31ifail=31
Constraint: n2n2.
  ifail = 51ifail=51
Constraint: ldxnldxn.
  ifail = 71ifail=71
On entry, iuld = _iuld=_.
Constraint: iuld = 1iuld=1, 22, 33, 44 or 55.
  ifail = 81ifail=81
On entry, ΣΣ is not positive semidefinite.
  ifail = 82ifail=82
On entry, at least one diagonal element of ΣΣ is less than or equal to 00.
  ifail = 83ifail=83
On entry, ΣΣ is not positive definite and eigenvalue decomposition failed.
  ifail = 91ifail=91
Constraint: if iuld = 3iuld=3, ldsig1ldsig1.
  ifail = 92ifail=92
Constraint: if iuld3iuld3, ldsignldsign.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_stat_pdf_multi_normal_vector_example
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] = nag_stat_pdf_multi_normal_vector(ilog, k, 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
 

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

function g01lb_example
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, k, 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
 

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–2013