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

NAG Library Routine Document

G01EFF

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

G01EFF returns the lower or upper tail probability of the gamma distribution, with parameters α and β, via the routine name.

2  Specification

FUNCTION G01EFF ( TAIL, G, A, B, IFAIL)
REAL (KIND=nag_wp) G01EFF
INTEGER  IFAIL
REAL (KIND=nag_wp)  G, A, B
CHARACTER(1)  TAIL

3  Description

The lower tail probability for the gamma distribution with parameters α and β, PGg, is defined by:
P Gg ; α,β = 1 βα Γα 0g Gα-1 e-G/β dG ,   α>0.0 , ​ β>0.0 .  
The mean of the distribution is αβ and its variance is αβ2. The transformation Z=Gβ is applied to yield the following incomplete gamma function in normalized form,
P Gg ; α ,β = P Zg/β : α,1.0 = 1 Γα 0g/β Zα-1 e-Z dZ .  
This is then evaluated using S14BAF.

4  References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth

5  Parameters

1:     TAIL – CHARACTER(1)Input
On entry: indicates whether an upper or lower tail probability is required.
TAIL='L'
The lower tail probability is returned, that is PGg:α,β.
TAIL='U'
The upper tail probability is returned, that is PGg:α,β.
Constraint: TAIL='L' or 'U'.
2:     G – REAL (KIND=nag_wp)Input
On entry: g, the value of the gamma variate.
Constraint: G0.0.
3:     A – REAL (KIND=nag_wp)Input
On entry: the parameter α of the gamma distribution.
Constraint: A>0.0.
4:     B – REAL (KIND=nag_wp)Input
On entry: the parameter β of the gamma distribution.
Constraint: B>0.0.
5:     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, if you are not familiar with this parameter, the recommended value is 0. 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).
Errors or warnings detected by the routine:
If IFAIL=1, 2, 3 or 4 on exit, then G01EFF returns 0.0.
IFAIL=1
On entry,TAIL'L' or 'U'.
IFAIL=2
On entry,G<0.0.
IFAIL=3
On entry,A0.0,
orB0.0.
IFAIL=4
The solution did not converge in 600 iterations. See S14BAF. The probability returned should be a reasonable approximation to the solution.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

The result should have a relative accuracy of machine precision. There are rare occasions when the relative accuracy attained is somewhat less than machine precision but the error should not exceed more than 1 or 2 decimal places. Note also that there is a limit of 18 decimal places on the achievable accuracy, because constants in S14BAF are given to this precision.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken by G01EFF varies slightly with the input parameters G, A and B.

10  Example

This example reads in values from a number of gamma distributions and computes the associated lower tail probabilities.

10.1  Program Text

Program Text (g01effe.f90)

10.2  Program Data

Program Data (g01effe.d)

10.3  Program Results

Program Results (g01effe.r)


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

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