NAG Library Function Document

nag_prob_lin_non_central_chi_sq (g01jcc)


    1  Purpose
    7  Accuracy


nag_prob_lin_non_central_chi_sq (g01jcc) returns the lower tail probability of a distribution of a positive linear combination of χ2 random variables.


#include <nag.h>
#include <nagg01.h>
void  nag_prob_lin_non_central_chi_sq (const double a[], const Integer mult[], const double rlamda[], Integer n, double c, double *p, double *pdf, double tol, Integer maxit, NagError *fail)


For a linear combination of noncentral χ2 random variables with integer degrees of freedom the lower tail probability is
P j=1najχ2mj,λjc , (1)
where aj and c are positive constants and where χ2mj,λj represents an independent χ2 random variable with mj degrees of freedom and noncentrality argument λ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 χ2m+2k<c/β , i.e., the probability that a central χ2 is less than c/β.
The value of β is set at
unless βB>1.8amin, in which case
is used, where amin=minaj and amax=maxaj, for j=1,2,,n.


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


1:     a[n] const doubleInput
On entry: the weights, a1,a2,,an.
Constraint: a[i]>0.0, for i=0,1,,n-1.
2:     mult[n] const IntegerInput
On entry: the degrees of freedom, m1,m2,,mn.
Constraint: mult[i]1, for i=0,1,,n-1.
3:     rlamda[n] const doubleInput
On entry: the noncentrality parameters, λ1,λ2,,λn.
Constraint: rlamda[i]0.0, for i=0,1,,n-1.
4:     n IntegerInput
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 doubleInput
On entry: c, the point for which the lower tail probability is to be evaluated.
Constraint: c0.0.
6:     p double *Output
On exit: the lower tail probability associated with the linear combination of n χ2 random variables with mj degrees of freedom, and noncentrality arguments λj, for j=1,2,,n.
7:     pdf double *Output
On exit: the value of the probability density function of the linear combination of χ2 variables.
8:     tol doubleInput
On entry: the relative accuracy required by you in the results. If nag_prob_lin_non_central_chi_sq (g01jcc) is entered with tol greater than or equal to 1.0 or less than 10×machine precision (see nag_machine_precision (X02AJC)), the value of 10×machine precision is used instead.
9:     maxit IntegerInput
On entry: the maximum number of terms that should be used during the summation.
Suggested value: 500.
Constraint: maxit1.
10:   fail NagError *Input/Output
The NAG error argument (see Section 3.7 in How to Use the NAG Library and its Documentation).

Error Indicators and Warnings

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.
Dynamic memory allocation failed.
See Section in How to Use the NAG Library and its Documentation for further information.
On entry, argument value had an illegal value.
The central χ2 calculation has failed to converge. This is an unlikely exit. A larger value of tol should be tried.
On entry, maxit=value.
Constraint: maxit1.
On entry, n=value.
Constraint: n1.
On entry, mult[value]=value.
Constraint: mult[i]1, for i=0,1,,n-1.
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
The solution appears to be too close to 0 or 1 for accurate calculation. The value returned is 0 or 1 as appropriate.
On entry, c=value.
Constraint: c0.0.
On entry, a[value]=value.
Constraint: a[i]>0.0, for i=0,1,,n-1.
On entry, rlamda[value]=value.
Constraint: rlamda[i]0.0, for i=0,1,,n-1.


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

Parallelism and Performance

nag_prob_lin_non_central_chi_sq (g01jcc) is not threaded in any implementation.

Further Comments



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

Program Text

Program Text (g01jcce.c)

Program Data

Program Data (g01jcce.d)

Program Results

Program Results (g01jcce.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017