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)


    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example


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


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


nag_specfun_beta_incomplete (s14cc) evaluates the incomplete beta function and its complement in the normalized form
Ixa,b = 1 Ba,b 0 x ta-1 1-t b-1 dt 1Ix a,b = Iy b,a , where ​ y=1-x ,  
Several methods are used to evaluate the functions depending on the arguments a, b and x. The methods include Wise's asymptotic expansion (see Wise (1950)) when a>b, continued fraction derived by DiDonato and Morris (1992) when a, b>1, and power series when b1 or b×x0.7. When both a and b are large, specifically a, b15, the DiDonato and Morris (1992) asymptotic expansion is employed for greater efficiency.
Once either Ixa,b or Iyb,a is computed, the other is obtained by subtraction from 1. In order to avoid loss of relative precision in this subtraction, the smaller of Ixa,b and Iyb,a is computed first.
nag_specfun_beta_incomplete (s14cc) is derived from BRATIO in DiDonato and Morris (1992).


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


Compulsory Input Parameters

1:     a – double scalar
The argument a of the function.
Constraint: a0.0.
2:     b – double scalar
The argument b of the function.
  • b0.0;
  • either b0.0 or a0.0.
3:     x – double scalar
x, upper limit of integration.
  • 0.0x1.0;
  • either x0.0 or a0.0;
  • either 1-x0.0 or b0.0.

Optional Input Parameters


Output Parameters

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

Error Indicators and Warnings

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


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



This example reads values of the arguments a and b from a file, evaluates the function and its complement for 10 different values of x and prints the results.
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);

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

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