NAG CL Interface
g01efc (prob_​gamma)

Settings help

CL Name Style:


1 Purpose

g01efc returns the lower or upper tail probability of the gamma distribution, with parameters α and β.

2 Specification

#include <nag.h>
double  g01efc (Nag_TailProbability tail, double g, double a, double b, NagError *fail)
The function may be called by the names: g01efc, nag_stat_prob_gamma or nag_gamma_dist.

3 Description

The lower tail probability for the gamma distribution with parameters α and β, P(Gg), 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 s14bac.

4 References

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

5 Arguments

1: tail Nag_TailProbability Input
On entry: indicates whether an upper or lower tail probability is required.
tail=Nag_LowerTail
The lower tail probability is returned, that is P(Gg:α,β).
tail=Nag_UpperTail
The upper tail probability is returned, that is P(Gg:α,β).
Constraint: tail=Nag_LowerTail or Nag_UpperTail.
2: g double Input
On entry: g, the value of the gamma variate.
Constraint: g0.0.
3: a double Input
On entry: the parameter α of the gamma distribution.
Constraint: a>0.0.
4: b double Input
On entry: the parameter β of the gamma distribution.
Constraint: b>0.0.
5: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

On any of the error conditions listed below except fail.code= NE_ALG_NOT_CONV g01efc returns 0.0.
NE_ALG_NOT_CONV
The algorithm has failed to converge in value iterations. The probability returned should be a reasonable approximation to the solution.
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_REAL_ARG_LE
On entry, a=value and b=value.
Constraint: a>0.0 and b>0.0.
NE_REAL_ARG_LT
On entry, g=value.
Constraint: g0.0.

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 s14bac are given to this precision.

8 Parallelism and Performance

g01efc is not threaded in any implementation.

9 Further Comments

The time taken by g01efc varies slightly with the input arguments 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 (g01efce.c)

10.2 Program Data

Program Data (g01efce.d)

10.3 Program Results

Program Results (g01efce.r)