farebro: Distribution of a Weighted Sum of Noncentral Chi-Squared...

View source: R/farebro.R

farebroR Documentation

Distribution of a Weighted Sum of Noncentral Chi-Squared Variables

Description

Calculates the cumulative probability distribution function and the probability density function of a weighted sum of noncentral chi-squared variables.

Usage

farebro(lambda, mult = 1, delta = 0, x, ...,
        maxit = 1e+06, eps = 1e-06, warn = TRUE)

Arguments

lambda

Numeric vector of positive weights.

mult

Integer value or integer vector of multiplicities (degrees of freedom).

delta

Numeric value or numeric vector of noncentrality parameters.

x

Numeric value or vector giving the function argument (quantiles for which the cumulative probability and density are desired).

...

Ignored.

maxit

Integer. Maximum number of iterations.

eps

Positive numeric value. Maximum error in the probability value.

warn

Logical value specifying whether to issue a warning if an error code is returned.

Details

This function implements the algorithm of Farebrother (1984) for computing the cumulative distribution function F(x) = P(X \le x) and probability density function f(x) = F^\prime(x) of the random variable

Y = \sum_{j=1}^n \lambda_j X_j

where X_1,\ldots,X_n are independent random variables and X_j has a noncentral \chi^2 distribution with m_j degrees of freedom and noncentrality parameter \delta_j.

The arguments lambda, mult and delta should be vectors of equal length, or will be recycled so that they have equal length.

The algorithm uses an exact mathematical representation of F(x) as an infinite series, and a mathematical upper bound on the error of the truncated series, to compute an approximation to F(x) which is guaranteed to be accurate to within the specified error eps. The algorithm involves calculating the probability density f(x) as well. It returns the values of both F(x) and f(x).

An error code ifault is returned for each entry of x. Nonzero error codes are translated to text warnings if warn=TRUE.

Value

A data frame, with one row for each entry in x, and columns x (input value), p (cumulative probability), d (probability density) and ifault (error code).

Author(s)

R.W. Farebrother, adapted by \adrian. Original Algol code of Farebrother (1984) translated to C by Adrian Baddeley and modified to handle a vector of quantile values. R interface by Adrian Baddeley.

References

Farebrother, R.W. (1984) Algorithm AS 204: The distribution of a positive linear combination of \chi^2 random variables. Applied Statistics 33 (3) 332–339.

See Also

dsocs

Examples

  ## Farebrother (1984) Table 1, example Q_5 (rows 13-15)
  farebro(c(7,3), c(6,2), c(6,2), c(20, 100, 200))

spatstat.univar documentation built on May 18, 2026, 9:06 a.m.