nonCentralFPdf

Evaluates the noncentral F probability density function (PDF).

Synopsis

nonCentralFPdf (f, dfNumerator, dfDenominator,  t_lambda)

Required Arguments

float f (Input)
Argument for which the noncentral F probability density 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_ambda must be non-negative.

Return Value

The probability density associated with a noncentral F random variable with value 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/v_1\right) / \left(Y/v_2\right)\]

is a noncentral F-distributed random variable whose PDF is given by

\[\mathit{PDF}\left(f|\nu_1,\nu_2,\lambda\right) = \mathit{\Psi} \sum_{k=0}^{\infty} \phi_k\]

where

\[\mathit{\Psi} = \frac {e^{-\lambda/2}\left(\nu_1 f\right)^{v_1/2}\left(\nu_2\right)^{v_2/2}} {f\left(\nu_1 f + \nu_2\right)^{\left(\nu_1+\nu_2\right)/2} \mathit{\Gamma}\left(\nu_2/2\right)}\]
\[\phi_k = \frac {R^k\mathit{\Gamma}\left(\frac{\nu_1 + \nu_2}{2} + k\right)} {k! \mathit{\Gamma}\left(\frac{\nu_1}{2} + k\right)}\]
\[R = \frac{\lambda \nu_1 f}{2 \left(\nu_1 f + \nu_2\right)}\]

and \(\Gamma(\cdot)\) is the gamma function, \(\nu_1\) = dfNumerator, \(\nu_2\) = dfDenominator, λ= t_lambda, and f = f.

With a noncentrality parameter of zero, the noncentral F distribution is the same as the F distribution.

The efficiency of the calculation of the above series is enhanced by:

  1. calculating each term \(\Phi_k\) in the series recursively in terms of either the term \(\Phi_{k-1}\) preceding it or the term \(\Phi_{k+1}\) following it, and.
  2. initializing the sum with the largest series term and adding the subsequent terms in order of decreasing magnitude

Special cases:

\[\begin{split}\begin{array}{c} \text{For } R = {\lambda}f = 0: \hfill \\ \phantom{\rule{1em}{0ex}} PDF(f|v_1,v_2,\lambda) = \mathit{\Psi\Phi}_0 = \mathit{\Psi}\frac{\mathit{\Gamma}\left(\left[v_1+v_2\right]/2\right)}{\mathit{\Gamma}(v_1/2)} \hfill \\ \text{For } \lambda = 0: \hfill \\ \phantom{\rule{1em}{0ex}} PDF(f|v_1,v_2,\lambda) = \frac {(v_1f)^{v_1/2}(v_2)^{v_2/2}\mathit{\Gamma}\left(\left[v_1+v_2\right]/2\right)} {f(v_1f+v_2)^{(v_1+v_2)/2}\mathit{\Gamma}(v_1/2)\mathit{\Gamma}(v_2/2)} \hfill \\ \text{For } f = 0: \hfill \\ \phantom{\rule{1em}{0ex}} PDF(f|v_1,v_2,\lambda) = \frac {e^{-\lambda/2}f^{v_1/2-1}(v_1/v_2)^{v_1/2}\mathit{\Gamma}\left(\left[v_1+v_2\right]/2\right)} {\mathit{\Gamma}(v_1/2)\mathit{\Gamma}(v_2/2)} = \begin{cases} 0 &\textit{ if } v_1 > 2; \\ e^{-\lambda/2} &\textit{ if } v_1 = 2 \\ \infty &\textit{ if } v_1 < 2 \\ \end{cases} \hfill \\ \end{array}\end{split}\]

Example

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

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

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):
    pdfv = nonCentralFPdf(f[i], df_numerator, df_denominator, lamb)
    print(" %5.1f  %12.4e" % (f[i], pdfv))

Output

df_numerator:    100
df_denominator:   10
lambda:           10

    f       pdf(f)
   0.0    0.0000e+00
   0.4    9.7488e-02
   0.8    8.1312e-01
   3.2    3.6948e-02
   5.6    2.8302e-03
   8.8    2.7661e-04
  14.0    2.1963e-05
  18.0    5.3483e-06