PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
tail was made optional (default 'L') |
Description
The lower tail probability for the gamma distribution with parameters
and
,
, is defined by:
The mean of the distribution is
and its variance is
. The transformation
is applied to yield the following incomplete gamma function in normalized form,
References
Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Parameters
Compulsory Input Parameters
- 1:
– double scalar
-
, the value of the gamma variate.
Constraint:
.
- 2:
– double scalar
-
The parameter of the gamma distribution.
Constraint:
.
- 3:
– double scalar
-
The parameter of the gamma distribution.
Constraint:
.
Optional Input Parameters
- 1:
– string (length ≥ 1)
Default:
Indicates whether an upper or lower tail probability is required.
- The lower tail probability is returned, that is .
- The upper tail probability is returned, that is .
Constraint:
or .
Output Parameters
- 1:
– double scalar
The result of the function.
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
If , , or on exit, then nag_stat_prob_gamma (g01ef) returns .
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
On entry, | or . |
-
-
-
-
- W
-
The solution did not converge in
iterations. See
nag_specfun_gamma_incomplete (s14ba). The probability returned should be a reasonable approximation to the solution.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
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
or
decimal places. Note also that there is a limit of
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 arguments
g,
a and
b.
Example
This example reads in values from a number of gamma distributions and computes the associated lower tail probabilities.
Open in the MATLAB editor:
g01ef_example
function g01ef_example
fprintf('g01ef example results\n\n');
g = [ 15.5; 0.5; 10.0; 5.0];
a = [ 4.0; 4.0; 1.0; 2.0];
b = [ 2.0; 1.0; 2.0; 2.0];
tail = {'Lower'; 'Lower'; 'Lower'; 'Lower'};
fprintf(' Tail G a b probability\n');
for j = 1:numel(g);
[p, ifail] = g01ef( ...
g(j), a(j), b(j), 'tail', tail{j});
fprintf('%4s%8.2f%8.2f%8.2f%12.4f\n', tail{j}(1), g(j), a(j), b(j), p);
end
g01ef example results
Tail G a b probability
L 15.50 4.00 2.00 0.9499
L 0.50 4.00 1.00 0.0018
L 10.00 1.00 2.00 0.9933
L 5.00 2.00 2.00 0.7127
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015