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_gamma (g01ef)

Purpose

nag_stat_prob_gamma (g01ef) returns the lower or upper tail probability of the gamma distribution, with parameters αα and ββ.

Syntax

[result, ifail] = g01ef(g, a, b, 'tail', tail)
[result, ifail] = nag_stat_prob_gamma(g, a, b, 'tail', tail)
Note: the interface to this routine has changed since earlier releases of the toolbox:
Mark 23: tail now optional (default 'l')
.

Description

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

References

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

Parameters

Compulsory Input Parameters

1:     g – double scalar
gg, the value of the gamma variate.
Constraint: g0.0g0.0.
2:     a – double scalar
The parameter αα of the gamma distribution.
Constraint: a > 0.0a>0.0.
3:     b – double scalar
The parameter ββ of the gamma distribution.
Constraint: b > 0.0b>0.0.

Optional Input Parameters

1:     tail – string (length ≥ 1)
Indicates whether an upper or lower tail probability is required.
tail = 'L'tail='L'
The lower tail probability is returned, that is P(Gg : α,β)P(Gg:α,β).
tail = 'U'tail='U'
The upper tail probability is returned, that is P(Gg : α,β)P(Gg:α,β).
Default: 'L''L'
Constraint: tail = 'L'tail='L' or 'U''U'.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     result – double scalar
The result of the function.
2:     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:
If ifail = 1ifail=1, 22, 33 or 44 on exit, then nag_stat_prob_gamma (g01ef) returns 0.00.0.

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,tail'L'tail'L' or 'U''U'.
  ifail = 2ifail=2
On entry,g < 0.0g<0.0.
  ifail = 3ifail=3
On entry,a0.0a0.0,
orb0.0b0.0.
W ifail = 4ifail=4
The solution did not converge in 600600 iterations. See nag_specfun_gamma_incomplete (s14ba). The probability returned should be a reasonable approximation to the solution.

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 11 or 22 decimal places. Note also that there is a limit of 1818 decimal places on the achievable accuracy, because constants in nag_specfun_gamma_incomplete (s14ba) are given to this precision.

Further Comments

The time taken by nag_stat_prob_gamma (g01ef) varies slightly with the input parameters g, a and b.

Example

function nag_stat_prob_gamma_example
g = 15.5;
a = 4;
b = 2;
[result, ifail] = nag_stat_prob_gamma(g, a, b)
 

result =

    0.9499


ifail =

                    0


function g01ef_example
g = 15.5;
a = 4;
b = 2;
[result, ifail] = g01ef(g, a, b)
 

result =

    0.9499


ifail =

                    0



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