The routine may be called by the names s14cqf or nagf_specfun_beta_incomplete_vector.
3Description
s14cqf evaluates the regularized incomplete beta function and its complement in the normalized form, for arrays of arguments , and , for . The incomplete beta function and its complement are given by
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.
DiDonato A R and Morris A H (1992) Algorithm 708: Significant digit computation of the incomplete beta function ratios ACM Trans. Math. Software18 360–373
Wise M E (1950) The incomplete beta function as a contour integral and a quickly converging series for its inverse Biometrika37 208–218
5Arguments
1: – IntegerInput
On entry: , the number of points.
Constraint:
.
2: – Real (Kind=nag_wp) arrayInput
On entry: the argument of the function, for .
Constraint:
, for .
3: – Real (Kind=nag_wp) arrayInput
On entry: the argument of the function, for .
Constraints:
, for ;
or , for .
4: – Real (Kind=nag_wp) arrayInput
On entry: , the upper limit of integration, for .
Constraints:
, for ;
or , for ;
or , for .
5: – Real (Kind=nag_wp) arrayOutput
On exit: the values of the incomplete beta function evaluated from zero to .
6: – Real (Kind=nag_wp) arrayOutput
On exit: the values of the complement of the incomplete beta function , i.e., the incomplete beta function evaluated from to one.
7: – Integer arrayOutput
On exit: contains the error code for the th evaluation, for .
No error.
.
Both .
.
Both .
Both .
8: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended. When the value or is used it is essential to test the value of ifail on exit.
On exit: unless the routine detects an error or a warning has been flagged (see Section 6).
6Error Indicators and Warnings
If on entry or , explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
On entry, at least one argument had an invalid value. Check ivalid for more information.
On entry, .
Constraint: .
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.
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.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
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.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
s14cqf is not threaded in any implementation.
9Further Comments
None.
10Example
This example reads values for each vector argument , and from a file. It then evaluates the function and its complement for each set of values.