NAG Library Function Document
nag_incomplete_beta (s14ccc)
1 Purpose
nag_incomplete_beta (s14ccc) computes values for the incomplete beta function and its complement .
2 Specification
#include <nag.h> |
#include <nags.h> |
void |
nag_incomplete_beta (double a,
double b,
double x,
double *w,
double *w1,
NagError *fail) |
|
3 Description
nag_incomplete_beta (s14ccc) 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.
nag_incomplete_beta (s14ccc) is derived from BRATIO in
DiDonato and Morris (1992).
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 Arguments
- 1:
– doubleInput
-
On entry: the argument of the function.
Constraint:
.
- 2:
– doubleInput
-
On entry: the argument of the function.
Constraints:
- ;
- either or .
- 3:
– doubleInput
-
On entry: , upper limit of integration.
Constraints:
- ;
- either or ;
- either or .
- 4:
– double *Output
-
On exit: the value of the incomplete beta function evaluated from zero to .
- 5:
– double *Output
-
On exit: the value of the complement of the incomplete beta function , i.e., the incomplete beta function evaluated from to one.
- 6:
– NagError *Input/Output
-
The NAG error argument (see
Section 2.7 in How to Use the NAG Library and its Documentation).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument 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.
An unexpected error has been triggered by this function. Please contact
NAG.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
- NE_REAL
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_REAL_2
-
On entry,
and
b were zero.
Constraint:
or
b must be nonzero.
On entry,
a and
b were zero.
Constraint:
a or
b must be nonzero.
On entry,
x and
a were zero.
Constraint:
x or
a must be nonzero.
7 Accuracy
nag_incomplete_beta (s14ccc) 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.
8 Parallelism and Performance
nag_incomplete_beta (s14ccc) is not threaded in any implementation.
None.
10 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.
10.1 Program Text
Program Text (s14ccce.c)
10.2 Program Data
Program Data (s14ccce.d)
10.3 Program Results
Program Results (s14ccce.r)