nonCentralFCdf

Evaluates the noncentral F cumulative distribution function (CDF).

Synopsis

nonCentralFCdf (f, dfNumerator, dfDenominator, t_lambda)

Required Arguments

float f (Input)
Argument for which the noncentral F cumulative distribution function is to be evaluated. f must be non-negative.
float dfNumerator (Input)
Numerator degrees of freedom of the noncentral F distribution. dfNumerator must be positive.
float dfDenominator (Input)
Denominator degrees of freedom of the noncentral F distribution. dfDenominator must be positive.
float t_lambda (Input)
Noncentrality parameter. t_lambda must be non-negative.

Return Value

The probability that a noncentral F random variable takes a value less than or equal to f.

Description

If X is a noncentral chi-square random variable with noncentrality parameter λ and \(\nu_1\) degrees of freedom, and Y is a chi-square random variable with \(\nu_2\) degrees of freedom which is statistically independent of X, then

\[F = \left(X/\nu_1\right) / \left(Y/\nu_2\right)\]

is a noncentral F-distributed random variable whose CDF is given by:

\[\mathit{CDF} \left(f|\nu_1,\nu_2,\lambda\right) = \sum_{j=0}^{\infty} c_j\]

where:

\[c_j = \omega_j I_x \left(\frac{\nu_1}{2} + j, \frac{\nu_2}{2}\right)\]
\[\omega_j = e^{-\lambda/2} \left(\lambda/2\right)^j/j! = \frac{\lambda}{2j} \omega_{j-1}\]
\[I_x(a,b) \equiv \textit{incomplete beta function ratio} \equiv \frac{B_x(a,b)}{B(a,b)}\]
\[B_x(a,b) \equiv \textit{incomplete beta function} \equiv \int_0^x t^{a-1} (1-t)^{b-1} dt\]
\[= x^a \sum_{j=0}^{\infty} \frac{\mathit{\Gamma}(j+1-b)}{(a+j)\mathit{\Gamma}(1-b)j!} x^j\]
\[x = \frac{v_1f}{\left(v_2 + v_1 f\right)} < = = > f = \frac{v_2x}{v_1(1-x)}\]
\[B(a,b) = B_1(a,b) = \frac{\mathit{\Gamma}(a)\mathit{\Gamma}(b)}{\mathit{\Gamma}(a+b)}\]
\[I_x(a+1,b) = I_x(a,b) - T_x(a,b)\]
\[T_x(a,b) = \frac{\mathit{\Gamma}(a+b)}{\mathit{\Gamma}(a+1) \mathit{\Gamma}(b)} x^a (1-x)^b = T_x(a-1,b) \frac{a-1+b}{a} x\]

and Γ (⋅) is the gamma function. The above series expansion for the noncentral F CDF was taken from Butler and Paolella (1999) (see Paolella.pdf), with the correction for the recursion relation given below:

\[I_x(a+1,b) = I_x(a,b) - T_x(a,b)\]

extracted from the AS 63 algorithm for calculating the incomplete beta function as described by Majumder and Bhattacharjee (1973).

The correspondence between the arguments of function nonCentralFCdf and the variables in the above equations is as follows: \(\nu_1\) = dfNumerator, \(\nu_2\) = dfDenominator, λ = t_lambda, and f = f.

For \(\lambda=0\), the noncentral F distribution is the same as the F distribution.

Example

This example traces out a portion of a noncentral F cumulative distribution function with parameters dfNumerator = 100, dfDenominator = 10, and t_lambda = 10.

from __future__ import print_function
from numpy import *
from pyimsl.stat.nonCentralFCdf import nonCentralFCdf

f = [0., .4, .8, 3.2, 5.6, 8.8, 14., 18.]
df_numerator = 100.
df_denominator = 10.
lamb = 10.

print("df_numerator:   %4.0f" % (df_numerator))
print("df_denominator: %4.0f" % (df_denominator))
print("lambda:         %4.0f\n" % (lamb))
print("    f       pdf(f)")

for i in range(0, 8):
    cdfv = nonCentralFCdf(f[i], df_numerator, df_denominator, lamb)
    print(" %5.1f  %12.4e" % (f[i], cdfv))

Output

df_numerator:    100
df_denominator:   10
lambda:           10

    f       pdf(f)
   0.0    0.0000e+00
   0.4    4.8879e-03
   0.8    2.0263e-01
   3.2    9.6667e-01
   5.6    9.9617e-01
   8.8    9.9945e-01
  14.0    9.9993e-01
  18.0    9.9998e-01