NAG FL Interface
s14cqf (beta_​incomplete_​vector)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

s14cqf computes an array of values for the regularized incomplete beta function Ix(a,b) and its complement 1-Ix(a,b).

2 Specification

Fortran Interface
Subroutine s14cqf ( n, a, b, x, w, w1, ivalid, ifail)
Integer, Intent (In) :: n
Integer, Intent (Inout) :: ifail
Integer, Intent (Out) :: ivalid(n)
Real (Kind=nag_wp), Intent (In) :: a(n), b(n), x(n)
Real (Kind=nag_wp), Intent (Out) :: w(n), w1(n)
C Header Interface
#include <nag.h>
void  s14cqf_ (const Integer *n, const double a[], const double b[], const double x[], double w[], double w1[], Integer ivalid[], Integer *ifail)
The routine may be called by the names s14cqf or nagf_specfun_beta_incomplete_vector.

3 Description

s14cqf evaluates the regularized incomplete beta function Ix(a,b) and its complement 1Ix(a,b) in the normalized form, for arrays of arguments xi, ai and bi, for i=1,2,,n. The incomplete beta function and its complement are given by
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 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 Ix(a,b) or Iy(b,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 Ix(a,b) and Iy(b,a) is computed first.
s14cqf 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: n Integer Input
On entry: n, the number of points.
Constraint: n0.
2: a(n) Real (Kind=nag_wp) array Input
On entry: the argument ai of the function, for i=1,2,,n.
Constraint: a(i)0.0, for i=1,2,,n.
3: b(n) Real (Kind=nag_wp) array Input
On entry: the argument bi of the function, for i=1,2,,n.
Constraints:
  • b(i)0.0, for i=1,2,,n;
  • b(i)0.0 or a(i)0.0, for i=1,2,,n.
4: x(n) Real (Kind=nag_wp) array Input
On entry: xi, the upper limit of integration, for i=1,2,,n.
Constraints:
  • x(i)0.0, for i=1,2,,n;
  • x(i)0.0 or a(i)0.0, for i=1,2,,n;
  • 1-x(i)0.0 or b(i)0.0, for i=1,2,,n.
5: w(n) Real (Kind=nag_wp) array Output
On exit: the values of the incomplete beta function Ixi(ai,bi) evaluated from zero to xi.
6: w1(n) Real (Kind=nag_wp) array Output
On exit: the values of the complement of the incomplete beta function 1-Ixi(ai,bi), i.e., the incomplete beta function evaluated from xi to one.
7: ivalid(n) Integer array Output
On exit: ivalid(i) contains the error code for the ith evaluation, for i=1,2,,n.
ivalid(i)=0
No error.
ivalid(i)=1
ai​ or ​bi<0.
ivalid(i)=2
Both ai​ and ​bi=0.
ivalid(i)=3
xi[0,1].
ivalid(i)=4
Both xi​ and ​ai=0.
ivalid(i)=5
Both 1-xi​ and ​bi=0.
8: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, at least one argument had an invalid value.
Check ivalid for more information.
ifail=2
On entry, n=value.
Constraint: n0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

s14cqf 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

s14cqf is not threaded in any implementation.

9 Further Comments

None.

10 Example

This example reads 10 values for each vector argument a, b and x from a file. It then evaluates the function and its complement for each set of values.

10.1 Program Text

Program Text (s14cqfe.f90)

10.2 Program Data

Program Data (s14cqfe.d)

10.3 Program Results

Program Results (s14cqfe.r)