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_prob_bivariate_normal (g01ha)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_stat_prob_bivariate_normal (g01ha) returns the lower tail probability for the bivariate Normal distribution.

Syntax

[result, ifail] = g01ha(x, y, rho)
[result, ifail] = nag_stat_prob_bivariate_normal(x, y, rho)

Description

For the two random variables X,Y following a bivariate Normal distribution with
EX=0,  EY=0,  EX2=1,  EY2=1  and  EXY=ρ,  
the lower tail probability is defined by:
PXx,Yy:ρ=12π1-ρ2 -y -x exp- X2- 2ρ XY+Y2 21-ρ2 dXdY.  
For a more detailed description of the bivariate Normal distribution and its properties see Abramowitz and Stegun (1972) and Kendall and Stuart (1969). The method used is described by Genz (2004).

References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Genz A (2004) Numerical computation of rectangular bivariate and trivariate Normal and t probabilities Statistics and Computing 14 151–160
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin

Parameters

Compulsory Input Parameters

1:     x – double scalar
x, the first argument for which the bivariate Normal distribution function is to be evaluated.
2:     y – double scalar
y, the second argument for which the bivariate Normal distribution function is to be evaluated.
3:     rho – double scalar
ρ, the correlation coefficient.
Constraint: -1.0rho1.0.

Optional Input Parameters

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     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=1
On entry,rho<-1.0,
orrho>1.0.
If on exit ifail=1 then nag_stat_prob_bivariate_normal (g01ha) returns zero.
   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

Accuracy of the hybrid algorithm implemented here is discussed in Genz (2004). This algorithm should give a maximum absolute error of less than 5×10-16.

Further Comments

The probabilities for the univariate Normal distribution can be computed using nag_specfun_cdf_normal (s15ab) and nag_specfun_compcdf_normal (s15ac).

Example

This example reads values of x and y for a bivariate Normal distribution along with the value of ρ and computes the lower tail probabilities.
function g01ha_example


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

x   = [    1.7    0      3.3     9.1];
y   = [   23.1    0     11.1     9.1 ];
rho = [    0      0.1    0.54    0.17];
p   = x;

fprintf('     x       y      rho      p\n');
for j = 1:numel(p)
   [p(j), ifail] = g01ha( ...
			  x(j), y(j), rho(j));
end

fprintf('%8.3f%8.3f%8.3f%8.4f\n', [x; y; rho; p]);


g01ha example results

     x       y      rho      p
   1.700  23.100   0.000  0.9554
   0.000   0.000   0.100  0.2659
   3.300  11.100   0.540  0.9995
   9.100   9.100   0.170  1.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