AS204: Algorithm AS 204

AS204R Documentation

Algorithm AS 204


Distribution of a positive linear combination of χ^2 random variables.


  mult = rep(1, length(lambda)),
  delta = rep(0, length(lambda)),
  maxit = 1e+05,
  eps = 1e-14,
  mode = 1



value point at which distribution is to be evaluated.


the weights λ_j.


the multiplicities m_j.


the non-centrality parameters δ^2_j.


the maximum number of terms K (see Details).


the desired level of accuracy.


if "mode" > 0 then β=modeλ_{min}, otherwise β=2/(1/λ_{min}+1/λ_{max}).


Algorithm AS 204 evaluates the expression

P [X < c] = P [ ∑_{j=1}^n λ_j χ^2(m_j, δ^2_j) < c ]

where λ_j and c are positive constants and χ^2(m_j, δ^2_j) represents an independent χ^2 random variable with m_j degrees of freedom and non-centrality parameter δ^2_j. This can be approximated by the truncated series

∑_{k=0}^{K-1} a_k P [χ^2(m+2k) < c/β]

where m = ∑_{j=1}^n m_j and β is an arbitrary constant (as given by argument "mode").

The C++ implementation of algorithm AS 204 used here is identical to the one employed by the farebrother method in the CompQuadForm package, with minor modifications.


The function returns the probability P[X > c] = 1 - P[X < c] if the AS 204 fault indicator is 0 (see Note below), and NULL if the fault indicator is 4, 5 or 9, as the corresponding faults can be corrected by increasing "eps". Other faults raise an error.


The algorithm AS 204 defines the following fault indicators: -j) one or more of the constraints λ_j > 0, m_j > 0 and δ^2_j ≥ 0 is not satisfied. 1) non-fatal underflow of a_0. 2) one or more of the constraints n > 0, c > 0, maxit > 0 and eps > 0 is not satisfied. 3) the current estimate of the probability is < -1. 4) the required accuracy could not be obtained in maxit iterations. 5) the value returned by the procedure does not satisfy 0 ≤ P [X < c] ≤ 1. 6) the density of the linear form is negative. 9) faults 4 and 5. 10) faults 4 and 6. 0) otherwise.


Diego Garrido-Martín


P. Duchesne, P. Lafaye de Micheaux, Computing the distribution of quadratic forms: Further comparisons between the Liu-Tang-Zhang approximation and exact methods, Computational Statistics and Data Analysis, Vol. 54, (2010), 858-862

Farebrother R.W., Algorithm AS 204: The distribution of a Positive Linear Combination of chi-squared random variables, Journal of the Royal Statistical Society, Series C (applied Statistics), Vol. 33, No. 3 (1984), 332-339

See Also


isglobal-brge/EpiMutations documentation built on Nov. 18, 2022, 3 p.m.