NAG Library Routine Document
S14CCF
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.
1 Purpose
S14CCF computes values for the incomplete beta function and its complement .
2 Specification
INTEGER
IFAIL
REAL (KIND=nag_wp)
A, B, X, W, W1
3 Description
S14CCF evaluates the incomplete beta function and its complement in the normalized form
with
- ,
- and ,
- and the beta function is defined as where is the gamma function.
Several methods are used to evaluate the functions depending on the arguments
,
and
. The methods include Wise's asymptotic expansion (see
Wise (1950)) when
, continued fraction derived by
DiDonato and Morris (1992) when
,
, and power series when
or
. When both
and
are large, specifically
,
, the
DiDonato and Morris (1992) asymptotic expansion is employed for greater efficiency.
Once either or is computed, the other is obtained by subtraction from . In order to avoid loss of relative precision in this subtraction, the smaller of and is computed first.
4 References
DiDonato A R and Morris A H (1992) Algorithm 708: Significant digit computation of the incomplete beta function ratios ACM Trans. Math. Software 18 360–373
Wise M E (1950) The incomplete beta function as a contour integral and a quickly converging series for its inverse Biometrika 37 208–218
5 Parameters
- 1: A – REAL (KIND=nag_wp)Input
On entry: the argument of the function.
Constraint:
.
- 2: B – REAL (KIND=nag_wp)Input
On entry: the argument of the function.
Constraints:
- ;
- either or .
- 3: X – REAL (KIND=nag_wp)Input
On entry: , upper limit of integration.
Constraints:
- ;
- either or ;
- either or .
- 4: W – REAL (KIND=nag_wp)Output
On exit: the value of the incomplete beta function evaluated from zero to .
- 5: W1 – REAL (KIND=nag_wp)Output
On exit: the value of the complement of the incomplete beta function , i.e., the incomplete beta function evaluated from to one.
- 6: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. 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
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry,
A and
B were zero.
Constraint:
A or
B must be nonzero.
-
On entry, .
Constraint: .
-
On entry,
X and
A were zero.
Constraint:
X or
A must be nonzero.
-
On entry,
and
B were zero.
Constraint:
or
B must be nonzero.
-
Dynamic memory allocation failed.
7 Accuracy
S14CCF is designed to maintain relative accuracy for all arguments. For very tiny results (of the order of machine precision or less) some relative accuracy may be lost – loss of three or four decimal places has been observed in experiments. For other arguments full relative accuracy may be expected.
None.
9 Example
This example reads values of the arguments and from a file, evaluates the function and its complement for different values of and prints the results.
9.1 Program Text
Program Text (s14ccfe.f90)
9.2 Program Data
Program Data (s14ccfe.d)
9.3 Program Results
Program Results (s14ccfe.r)