g01ff returns the deviate associated with the given lower tail probability of the gamma distribution.
Syntax
C# |
---|
public static double g01ff( double p, double a, double b, double tol, out int ifail ) |
Visual Basic |
---|
Public Shared Function g01ff ( _ p As Double, _ a As Double, _ b As Double, _ tol As Double, _ <OutAttribute> ByRef ifail As Integer _ ) As Double |
Visual C++ |
---|
public: static double g01ff( double p, double a, double b, double tol, [OutAttribute] int% ifail ) |
F# |
---|
static member g01ff : p : float * a : float * b : float * tol : float * ifail : int byref -> float |
Parameters
- p
- Type: System..::..DoubleOn entry: , the lower tail probability from the required gamma distribution.Constraint: .
- a
- Type: System..::..DoubleOn entry: , the shape parameter of the gamma distribution.Constraint: .
- b
- Type: System..::..DoubleOn entry: , the scale parameter of the gamma distribution.Constraint: .
- tol
- Type: System..::..Double
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Return Value
g01ff returns the deviate associated with the given lower tail probability of the gamma distribution.
Description
The deviate, , associated with the lower tail probability, , of the gamma distribution with shape parameter and scale parameter , is defined as the solution to
The method used is described by Best and Roberts (1975) making use of the relationship between the gamma distribution and the -distribution.
Let . The required is found from the Taylor series expansion
where is a starting approximation
- ,
- ,
- ,
- ,
- .
For most values of and the starting value
is used, where is the deviate associated with a lower tail probability of for the standard Normal distribution.
For close to zero,
is used.
For large values, when ,
is found to be a better starting value than .
For small , is expressed in terms of an approximation to the exponential integral and is found by Newton–Raphson iterations.
Seven terms of the Taylor series are used to refine the starting approximation, repeating the process if necessary until the required accuracy is obtained.
References
Best D J and Roberts D E (1975) Algorithm AS 91. The percentage points of the distribution Appl. Statist. 24 385–388
Error Indicators and Warnings
Note: g01ff may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the method:
If on exit , , or , then g01ff returns .
On entry, , or ,
On entry, , or , or
- p is too close to or to enable the result to be calculated.
- The solution has failed to converge in iterations. A larger value of tol should be tried. The result may be a reasonable approximation.
- The series to calculate the gamma function has failed to converge. This is an unlikely error exit.
Accuracy
In most cases the relative accuracy of the results should be as specified by tol. However, for very small values of or very small values of there may be some loss of accuracy.
Parallelism and Performance
None.
Further Comments
None.
Example
This example reads lower tail probabilities for several gamma distributions, and calculates and prints the corresponding deviates until the end of data is reached.
Example program (C#): g01ffe.cs