PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_specfun_beta_incomplete (s14cc)
Purpose
nag_specfun_beta_incomplete (s14cc) computes values for the incomplete beta function and its complement .
Syntax
Description
nag_specfun_beta_incomplete (s14cc) 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_specfun_beta_incomplete (s14cc) is derived from BRATIO in
DiDonato and Morris (1992).
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
Parameters
Compulsory Input Parameters
- 1:
– double scalar
-
The argument of the function.
Constraint:
.
- 2:
– double scalar
-
The argument of the function.
Constraints:
- ;
- either or .
- 3:
– double scalar
-
, upper limit of integration.
Constraints:
- ;
- either or ;
- either or .
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
-
The value of the incomplete beta function evaluated from zero to .
- 2:
– double scalar
-
The value of the complement of the incomplete beta function , i.e., the incomplete beta function evaluated from to one.
- 3:
– 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:
-
-
Constraint: .
Constraint: .
-
-
On entry,
a and
b were zero.
Constraint:
a or
b must be nonzero.
-
-
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.
-
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
nag_specfun_beta_incomplete (s14cc) 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.
Further Comments
None.
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.
Open in the MATLAB editor:
s14cc_example
function s14cc_example
fprintf('s14cc example results\n\n');
a = 5.3;
b = 10.1;
fprintf('\n a b x Ix(a,b) 1-Ix(a,b)\n');
for x = 0.01:0.01:0.1
[w, w1, ifail] = s14cc(a, b, x);
fprintf('%6.2f%6.2f%6.2f%17.4e%17.4e\n', a, b, x, w, w1);
end
s14cc example results
a b x Ix(a,b) 1-Ix(a,b)
5.30 10.10 0.01 6.4755e-08 1.0000e+00
5.30 10.10 0.02 2.3613e-06 1.0000e+00
5.30 10.10 0.03 1.8734e-05 9.9998e-01
5.30 10.10 0.04 7.9575e-05 9.9992e-01
5.30 10.10 0.05 2.3997e-04 9.9976e-01
5.30 10.10 0.06 5.8255e-04 9.9942e-01
5.30 10.10 0.07 1.2174e-03 9.9878e-01
5.30 10.10 0.08 2.2797e-03 9.9772e-01
5.30 10.10 0.09 3.9249e-03 9.9608e-01
5.30 10.10 0.10 6.3236e-03 9.9368e-01
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015