complementaryNonCentralFCdf

Evaluates the complementary noncentral F cumulative distribution function (CDF).

Synopsis

complementaryNonCentralFCdf (f, dfNumerator, dfDenominator, t_lambda)

Required Arguments

float f (Input)
Argument for which the complementary noncentral F cumulative distribution function is to be evaluated. f must be non-negative.
float dfNumerator (Input)
Numerator degrees of freedom of the complementary noncentral F distribution. dfNumerator must be positive.
float dfDenominator (Input)
Denominator degrees of freedom of the complementary 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 greater than 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:

\[F\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, denoted by F(⋅), 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 series approximation of the complementary (cmp) noncentral F CDF, denoted by F(⋅), is obtainable by using the following identities:

\[\sum_{j=0}^{\infty} \omega_j = 1\]
\[I_{1-x}(b,a) = 1 - I_x(a,b)\]
\[I_{1-x}(b,a + 1) = 1 - I_x(a + 1,b) = 1 - I_x(a,b) + T_x(a,b) = I_{1-x}(b,a) + T_x(a,b)\]

Thus:

\[\begin{split}\begin{aligned} \overline{F}\left(f|v_1,v_2,\lambda\right) = 1 - \sum_{j=0}^{\infty} c_j &= \sum_{j=0}^{\infty} \omega_j \left[ 1 - I_x \left(\frac{v_1}{2} + j, \frac{v_2}{2}\right) \right] \\ &= \sum_{j=0}^{\infty} \omega_jI_{1-x} \left(\frac{v_2}{2}, \frac{v_1}{2} + j\right) \end{aligned}\end{split}\]

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

Also, we can use the above expansion of \(\overline{F} \left( f | v_1,v_2,\lambda\right)\) and the identities:

\[I_{1-x}(b,a+1) = I_{1-x}(b,a) + 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\]

to recursively calculate \(\overline{F} \left( f | \nu_1,\nu_2,\lambda\right)\).

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

Example

This example traces out a portion of a complementary 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.complementaryNonCentralFCdf import complementaryNonCentralFCdf

f = [0., .4, .8, 1.2, 1.6, 2.0, 2.8, 4.0]
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      cmpCDF(f)")

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

Output

df_numerator:       100
df_denominator:      10
lambda:              10

    f      cmpCDF(f)
   0.0    1.0000e+00
   0.4    9.9511e-01
   0.8    7.9737e-01
   1.2    4.7886e-01
   1.6    2.6615e-01
   2.0    1.4959e-01
   2.8    5.2875e-02
   4.0    1.4642e-02