NAG FL Interface
g01jcf (prob_​chisq_​noncentral_​lincomb)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01jcf returns the lower tail probability of a distribution of a positive linear combination of χ2 random variables.

2 Specification

Fortran Interface
Subroutine g01jcf ( a, mult, rlamda, n, c, p, pdf, tol, maxit, wrk, ifail)
Integer, Intent (In) :: mult(n), n, maxit
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: a(n), rlamda(n), c, tol
Real (Kind=nag_wp), Intent (Out) :: p, pdf, wrk(n+2*maxit)
C Header Interface
#include <nag.h>
void  g01jcf_ (const double a[], const Integer mult[], const double rlamda[], const Integer *n, const double *c, double *p, double *pdf, const double *tol, const Integer *maxit, double wrk[], Integer *ifail)
The routine may be called by the names g01jcf or nagf_stat_prob_chisq_noncentral_lincomb.

3 Description

For a linear combination of noncentral χ2 random variables with integer degrees of freedom the lower tail probability is
P (j=1najχ2(mj,λj)c) , (1)
where aj and c are positive constants and where χ2(mj,λj) represents an independent χ2 random variable with mj degrees of freedom and noncentrality parameter λj. The linear combination may arise from considering a quadratic form in Normal variables.
Ruben's method as described in Farebrother (1984) is used. Ruben has shown that (1) may be expanded as an infinite series of the form
k=0dkF (m+2k,c/β) , (2)
where F (m+2k,c/β)=P (χ2(m+2k)<c/β) , i.e., the probability that a central χ2 is less than c/β.
The value of β is set at
β=βB=2(1/amin+1/amax)  
unless βB>1.8amin, in which case
β=βA=amin  
is used, where amin=min{aj} and amax=max{aj}, for j=1,2,,n.

4 References

Farebrother R W (1984) The distribution of a positive linear combination of χ2 random variables Appl. Statist. 33(3)

5 Arguments

1: a(n) Real (Kind=nag_wp) array Input
On entry: the weights, a1,a2,,an.
Constraint: a(i)>0.0, for i=1,2,,n.
2: mult(n) Integer array Input
On entry: the degrees of freedom, m1,m2,,mn.
Constraint: mult(i)1, for i=1,2,,n.
3: rlamda(n) Real (Kind=nag_wp) array Input
On entry: the noncentrality parameters, λ1,λ2,,λn.
Constraint: rlamda(i)0.0, for i=1,2,,n.
4: n Integer Input
On entry: n, the number of χ2 random variables in the combination, i.e., the number of terms in equation (1).
Constraint: n1.
5: c Real (Kind=nag_wp) Input
On entry: c, the point for which the lower tail probability is to be evaluated.
Constraint: c0.0.
6: p Real (Kind=nag_wp) Output
On exit: the lower tail probability associated with the linear combination of n χ2 random variables with mj degrees of freedom, and noncentrality parameters λj, for j=1,2,,n.
7: pdf Real (Kind=nag_wp) Output
On exit: the value of the probability density function of the linear combination of χ2 variables.
8: tol Real (Kind=nag_wp) Input
On entry: the relative accuracy required by you in the results. If g01jcf is entered with tol greater than or equal to 1.0 or less than 10×machine precision (see x02ajf), the value of 10×machine precision is used instead.
9: maxit Integer Input
On entry: the maximum number of terms that should be used during the summation.
Suggested value: 500.
Constraint: maxit1.
10: wrk(n+2×maxit) Real (Kind=nag_wp) array Workspace
11: 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 -1 is recommended since useful values can be provided in some output arguments even when ifail0 on exit. 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:
Note: in some cases g01jcf may return useful information.
If on exit ifail=1 or 2, then g01jcf returns 0.0.
ifail=1
On entry, c=value.
Constraint: c0.0.
On entry, maxit=value.
Constraint: maxit1.
On entry, n=value.
Constraint: n1.
ifail=2
On entry, a(value)=value.
Constraint: a(i)>0.0, for i=1,2,,n.
On entry, mult(value)=value.
Constraint: mult(i)1, for i=1,2,,n.
On entry, rlamda(value)=value.
Constraint: rlamda(i)0.0, for i=1,2,,n.
ifail=3
The central χ2 calculation has failed to converge. This is an unlikely exit. A larger value of tol should be tried.
ifail=4
The solution has failed to converge within maxit iterations. A larger value of maxit or tol should be used. The returned value should be a reasonable approximation to the correct value.
ifail=5
The solution appears to be too close to 0 or 1 for accurate calculation. The value returned is 0 or 1 as appropriate.
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

The series (2) is summed until a bound on the truncation error is less than tol. See Farebrother (1984) for further discussion.

8 Parallelism and Performance

g01jcf is not threaded in any implementation.

9 Further Comments

None.

10 Example

The number of χ2 variables is read along with their coefficients, degrees of freedom and noncentrality parameters. The lower tail probability is then computed and printed.

10.1 Program Text

Program Text (g01jcfe.f90)

10.2 Program Data

Program Data (g01jcfe.d)

10.3 Program Results

Program Results (g01jcfe.r)