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_stat_prob_chisq_noncentral_lincomb (g01jc)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

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

Syntax

[p, pdf, ifail] = g01jc(a, mult, rlamda, c, 'n', n, 'tol', tol, 'maxit', maxit)
[p, pdf, ifail] = nag_stat_prob_chisq_noncentral_lincomb(a, mult, rlamda, c, 'n', n, 'tol', tol, 'maxit', maxit)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: tol was made optional (default 0)

Description

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
β=βB=21/amin+1/amax  
unless βB>1.8amin, in which case
β=βA=amin  
is used, where amin=minaj and amax=maxaj, for j=1,2,,n.

References

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

Parameters

Compulsory Input Parameters

1:     an – double array
The weights, a1,a2,,an.
Constraint: ai>0.0, for i=1,2,,n.
2:     multn int64int32nag_int array
The degrees of freedom, m1,m2,,mn.
Constraint: multi1, for i=1,2,,n.
3:     rlamdan – double array
The noncentrality parameters, λ1,λ2,,λn.
Constraint: rlamdai0.0, for i=1,2,,n.
4:     c – double scalar
c, the point for which the lower tail probability is to be evaluated.
Constraint: c0.0.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the dimension of the arrays a, mult, rlamda. (An error is raised if these dimensions are not equal.)
n, the number of χ2 random variables in the combination, i.e., the number of terms in equation (1).
Constraint: n1.
2:     tol – double scalar
Default: 0
The relative accuracy required by you in the results. If nag_stat_prob_chisq_noncentral_lincomb (g01jc) is entered with tol greater than or equal to 1.0 or less than 10×machine precision (see nag_machine_precision (x02aj)), then the value of 10×machine precision is used instead.
3:     maxit int64int32nag_int scalar
Default: 500.
The maximum number of terms that should be used during the summation.
Constraint: maxit1.

Output Parameters

1:     p – double scalar
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.
2:     pdf – double scalar
The value of the probability density function of the linear combination of χ2 variables.
3:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Note: nag_stat_prob_chisq_noncentral_lincomb (g01jc) may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the function:
If on exit ifail=1 or 2, then nag_stat_prob_chisq_noncentral_lincomb (g01jc) returns 0.0.

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

   ifail=1
On entry,n<1,
ormaxit<1,
orc<0.0.
   ifail=2
On entry,a has an element 0.0,
ormult has an element <1,
orrlamda has an element <0.0.
   ifail=3
The central χ2 calculation has failed to converge. This is an unlikely exit. A larger value of tol should be tried.
W  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.
W  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.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

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

Further Comments

None.

Example

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.
function g01jc_example


fprintf('g01jc example results\n\n');

fprintf('        a     mult  rlamda\n');

% First set
a      = [        6   3  1];
mult   = [int64(1)  1  1];
rlamda = [        0   0  0];
c      = 20;

[p1, pdf, ifail] = g01jc( ...
			  a, mult, rlamda, c);

fprintf('%10.2f%6d%9.2f\n',[a; mult; rlamda]);
fprintf('c = %6.2f    prob = %6.4f\n\n', c, p1);

% Second set
a      = [        7   3];
mult   = [int64(1)  1];
rlamda = [        6   2];
c      = 10;

[p2, pdf, ifail] = g01jc( ...
			  a, mult, rlamda, c);

fprintf('%10.2f%6d%9.2f\n',[a; mult; rlamda]);
fprintf('c = %6.2f    prob = %6.4f\n', c, p2);


g01jc example results

        a     mult  rlamda
      6.00     1     0.00
      3.00     1     0.00
      1.00     1     0.00
c =  20.00    prob = 0.8760

      7.00     1     6.00
      3.00     1     2.00
c =  10.00    prob = 0.0451

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