hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_specfun_beta_incomplete (s14cc)

Purpose

nag_specfun_beta_incomplete (s14cc) computes values for the incomplete beta function Ix(a,b)Ix(a,b) and its complement 1Ix(a,b)1-Ix(a,b).

Syntax

[w, w1, ifail] = s14cc(a, b, x)
[w, w1, ifail] = nag_specfun_beta_incomplete(a, b, x)

Description

nag_specfun_beta_incomplete (s14cc) evaluates the incomplete beta function and its complement in the normalized form
Ix(a,b) =
x
1/(B(a,b))ta1(1t)b1dt
0
1Ix (a,b) = Iy (b,a) , where ​ y = 1x ,
Ix(a,b) = 1 B(a,b) 0 x ta-1 (1-t) b-1 dt 1Ix (a,b) = Iy (b,a) , where ​ y=1-x ,
with
Several methods are used to evaluate the functions depending on the arguments aa, bb and xx. The methods include Wise's asymptotic expansion (see Wise (1950)) when a > ba>b, continued fraction derived by DiDonato and Morris (1992) when aa, b > 1b>1, and power series when b1b1 or b × x0.7b×x0.7. When both aa and bb are large, specifically aa, b15b15, the DiDonato and Morris (1992) asymptotic expansion is employed for greater efficiency.
Once either Ix(a,b)Ix(a,b) or Iy(b,a)Iy(b,a) is computed, the other is obtained by subtraction from 11. In order to avoid loss of relative precision in this subtraction, the smaller of Ix(a,b)Ix(a,b) and Iy(b,a)Iy(b,a) 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:     a – double scalar
The argument aa of the function.
Constraint: a0.0a0.0.
2:     b – double scalar
The argument bb of the function.
Constraints:
  • b0.0b0.0;
  • either b0.0b0.0 or a0.0a0.0.
3:     x – double scalar
xx, upper limit of integration.
Constraints:
  • 0.0x1.00.0x1.0;
  • either x0.0x0.0 or a0.0a0.0;
  • either 1x0.01-x0.0 or b0.0b0.0.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     w – double scalar
The value of the incomplete beta function Ix(a,b)Ix(a,b) evaluated from zero to xx.
2:     w1 – double scalar
The value of the complement of the incomplete beta function 1Ix(a,b)1-Ix(a,b), i.e., the incomplete beta function evaluated from xx to one.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
Constraint: a0.0a0.0.
Constraint: b0.0b0.0.
  ifail = 2ifail=2
On entry, a and b were zero.
Constraint: a or b must be nonzero.
  ifail = 3ifail=3
Constraint: 0.0x1.00.0x1.0.
  ifail = 4ifail=4
On entry, x and a were zero.
Constraint: x or a must be nonzero.
  ifail = 5ifail=5
On entry, 1.0x1.0-x and b were zero.
Constraint: 1.0x1.0-x or b must be nonzero.
  ifail = 999ifail=-999
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

function nag_specfun_beta_incomplete_example
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] = nag_specfun_beta_incomplete(a, b, x);
  fprintf('%6.2f%6.2f%6.2f%17.4e%17.4e\n', a, b, x, w, w1);
end
 

   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

function s14cc_example
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
 

   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)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013