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

NAG Library Routine Document


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

G01HBF returns the upper tail, lower tail or central probability associated with a multivariate Normal distribution of up to ten dimensions.

2  Specification

REAL (KIND=nag_wp) G01HBF
REAL (KIND=nag_wp)  A(N), B(N), XMU(N), SIG(LDSIG,N), TOL, WK(LWK)

3  Description

Let the vector random variable X = X1,X2,,XnT  follow an n-dimensional multivariate Normal distribution with mean vector μ and n by n variance-covariance matrix Σ, then the probability density function, fX:μ,Σ, is given by
fX:μ,Σ = 2π - 1/2 n Σ -1/2 exp -12 X-μT Σ-1 X-μ .
The lower tail probability is defined by:
PX1b1,,Xnbn: μ ,Σ=- b1- bnfX : μ ,Σ dXndX1.
The upper tail probability is defined by:
The central probability is defined by:
Pa1X1b1,,anXnbn: μ ,Σ=a1b1anbnfX : μ ,Σ dXndX1.
To evaluate the probability for n3, the probability density function of X1,X2,,Xn is considered as the product of the conditional probability of X1,X2,,Xn-2 given Xn-1 and Xn and the marginal bivariate Normal distribution of Xn-1 and Xn. The bivariate Normal probability can be evaluated as described in G01HAF and numerical integration is then used over the remaining n-2 dimensions. In the case of n=3, D01AJF is used and for n>3 D01FCF is used.
To evaluate the probability for n=1 a direct call to G01EAF is made and for n=2 calls to G01HAF are made.

4  References

Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin

5  Parameters

1:     TAIL – CHARACTER(1)Input
On entry: indicates which probability is to be returned.
The lower tail probability is returned.
The upper tail probability is returned.
The central probability is returned.
Constraint: TAIL='L', 'U' or 'C'.
2:     N – INTEGERInput
On entry: n, the number of dimensions.
Constraint: 1N10.
3:     A(N) – REAL (KIND=nag_wp) arrayInput
On entry: if TAIL='C' or 'U', the lower bounds, ai, for i=1,2,,n.
If TAIL='L', A is not referenced.
4:     B(N) – REAL (KIND=nag_wp) arrayInput
On entry: if TAIL='C' or 'L', the upper bounds, bi, for i=1,2,,n.
If TAIL='U' B, is not referenced.
Constraint: if TAIL='C', Ai<Bi, for i=1,2,,n.
5:     XMU(N) – REAL (KIND=nag_wp) arrayInput
On entry: μ, the mean vector of the multivariate Normal distribution.
6:     SIG(LDSIG,N) – REAL (KIND=nag_wp) arrayInput
On entry: Σ, the variance-covariance matrix of the multivariate Normal distribution. Only the lower triangle is referenced.
Constraint: Σ must be positive definite.
7:     LDSIG – INTEGERInput
On entry: the first dimension of the array SIG as declared in the (sub)program from which G01HBF is called.
Constraint: LDSIGN.
8:     TOL – REAL (KIND=nag_wp)Input
On entry: if n>2 the relative accuracy required for the probability, and if the upper or the lower tail probability is requested then TOL is also used to determine the cut-off points, see Section 7.
If n=1, TOL is not referenced.
Suggested value: TOL=0.0001.
Constraint: if N>1, TOL>0.0.
9:     WK(LWK) – REAL (KIND=nag_wp) arrayWorkspace
10:   LWK – INTEGERInput
On entry: the length of workspace provided in array WK. This workspace is used by the numerical integration routines D01AJF for n=3 and D01FCF for n>3.
If n=3, then the maximum number of sub-intervals used by D01AJF is LWK/4. Note, however, increasing LWK above 1000 will not increase the maximum number of sub-intervals above 250.
If n>3 the maximum number of integrand evaluations used by D01FCF is αLWK/n-1, where α=2n-2+2 n-2 2+2n-2+1.
If n=1​ or ​2, then WK will not be used.
Suggested value: 2000 if n>3 and 1000 if n=3.
  • if N=1, LWK1;
  • if N3, LWK4×N.
11:   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, because for this routine the values of the output parameters may be useful even if IFAIL0 on exit, the recommended value is -1. 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).
Note: G01HBF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
If on exit IFAIL=1, 2 or 3, then G01HBF returns zero.
On entry,N<1,
orTAIL'L', 'U' or 'C',
orN>1 and TOL0.0,
orLWK is too small.
On entry,TAIL='C' and AiBi, for some i=1,2,,n.
On entry,Σ is not positive definite, i.e., is not a correct variance-covariance matrix.
The requested accuracy has not been achieved, a larger value of TOL should be tried or the length of the workspace should be increased. The returned value will be an approximation to the required result.
Round-off error prevents the requested accuracy from being achieved; a larger value of TOL should be tried. The returned value will be an approximation to the required result. This error will only occur if n=3.

7  Accuracy

The accuracy should be as specified by TOL. When on exit IFAIL=4 the approximate accuracy achieved is given in the error message. For the upper and lower tail probabilities the infinite limits are approximated by cut-off points for the n-2 dimensions over which the numerical integration takes place; these cut-off points are given by Φ-1TOL/10×n, where Φ-1 is the inverse univariate Normal distribution function.

8  Further Comments

The time taken is related to the number of dimensions, the range over which the integration takes place (bi-ai, for i=1,2,,n) and the value of Σ as well as the accuracy required. As the numerical integration does not take place over the last two dimensions speed may be improved by arranging X so that the largest ranges of integration are for Xn-1 and Xn.

9  Example

This example reads in the mean and covariance matrix for a multivariate Normal distribution and computes and prints the associated central probability.

9.1  Program Text

Program Text (g01hbfe.f90)

9.2  Program Data

Program Data (g01hbfe.d)

9.3  Program Results

Program Results (g01hbfe.r)

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

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