Boost: Central Fisher F distribution#
The following functions return the pdf, cdf, qtf or boost class of the Fisher F distribution with \(m > 0\) and \(n > 0\) degrees of freedom, and the support interval \((0, +\infty)\).
See also Wikipedia [1243], MathWorld [872], BoostMath [62], Ehrhardt [309] (3.9.9).
- Ctx.fisher_f_pdf(x, m, n)#
where
CtxisMath53orCtxBoost.Returns \(\text{pdf}(x)\), the value of the probability density function (Pdf) of the Fisher F distribution:
\[\text{pdf}(x) = \frac{m^{m/2} n^{n/2}}{B(m/2,n/2)} x^{(m-2)/2} (n+mx)^{-(m+n)/2}.\]The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("FisherFPdf(x, a, b): ", FisherFPdf(x, a, b)) >>> print ("dist_fisher_f(a, b).pdf(x): ", dist_fisher_f(a, b).pdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.fisher_f_cdf(x, m, n)#
where
CtxisMath53orCtxBoost.Returns \(\text{cdf}(x)\), the value of the cumulative distribution function (Cdf) of the Fisher F distribution:
\[\begin{split}\text{cdf}(x) =\begin{cases} \text{ibetac}(n/2, m/2, n/(n+mx)), & mx > n,\\ \text{ibeta}(m/2, n/2, mx/(n+mx)) & mx \le n. \end{cases}\end{split}\]Here \(\text{ibeta}(\cdot)\) denotes the real normalised incomplete beta function (RealIBeta), and \(\text{ibetac}(\cdot)\) denotes the real normalised complementary incomplete beta function (RealIBetac).
The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; x = 0.6; >>> print ("FisherFCdf(x, a, b): ", FisherFCdf(x, a, b)) >>> print ("dist_fisher_f(a, b).cdf(x): ", dist_fisher_f(a, b).cdf(x)) 6.3563523462564525615615615614561356E+00
- Ctx.fisher_f_qtf(q, m, n)#
where
CtxisMath53orCtxBoost.Returns \(\text{qtf}(q)\), the value of the quantile function (Qtf) of the Fisher F distribution:
\[\text{qtf}(q) = \frac{nx}{m(1-x)}, \quad \text{where } x = \mathrm{ibeta\_inv}(m/2, n/2, q).\]Here \(\mathrm{ibeta\_inv}(\cdot)\) denotes the inverse of the real normalised incomplete beta function (RealIBetaInv).
The following example shows both forms of the syntax:
>>> from mpfebnet import * >>> a = 0; b = 1; t = 0.3; q = 0.6; >>> print ("FisherFQtf(q, a, b): ", FisherFQtf(q, a, b)) >>> print ("dist_fisher_f(a, b).qtf(q): ", dist_fisher_f(a, b).qtf(q)) 6.3563523462564525615615615614561356E+00
- class ctx.dist_fisher_f(m, n)#
where
ctxisfpm,mpm,ipm,dec,gmporapm.The Fisher \(F\)-distribution is a continuous probability distribution with \(m > 0\) and \(n > 0\) degrees of freedom, and the support interval \((0, +\infty)\). See also Wikipedia [1243], MathWorld [872], BoostMath [62], Witkovský [1617], R (Statistical System) [549], Abramowitz and Stegun. [3], Butler and Paolella [173], Chattamvelli and Jones [182], Witkovský [1611].
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.fdtr.html#scipy.special.fdtr
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.fdtrc.html#scipy.special.fdtrc
See also: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.fdtri.html#scipy.special.fdtri
- dist_fisher_f.pdf(x)#
Returns \(\text{pdf}_X(x)\), the probability density function (pdf) of a random variable \(X\), following a central Fisher F distribution:
\[\text{pdf}_X(x) = \frac{m^{m/2} n^{n/2}}{B(m/2,n/2)} x^{(m-2)/2} (n+mx)^{-(m+n)/2},\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("pdf: ", fisher_f(mu, sigma).pdf(x)) 6.3563523462564525615615615614561356E-20
- dist_fisher_f.cdf(x)#
Returns \(\text{cdf}_X(x)\), the cumulative distribution function (cdf) of a random variable \(X\), following a central Fisher F distribution:
\[\begin{split}\text{cdf}_X(x) =\begin{cases} \text{ibetac}(n/2, m/2, n/(n+mx)), & mx > n,\\ \text{ibeta}(m/2, n/2, mx/(n+mx)) & mx \le n. \end{cases}\end{split}\]Here \(\text{ibeta}(\cdot)\) denotes the real normalised incomplete beta function, and \(\text{ibetac}(\cdot)\) denotes the real normalised complementary incomplete beta function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print ("cdf: ", fisher_f(mu, sigma).pdf(x)) 6.3563523462564525615615615614561356E-20
- dist_fisher_f.sf(x)#
Returns \(\text{sf}_X(x)\), the survival function (sf) of a random variable \(X\), following a central Fisher F distribution:
\[\begin{split}\text{sf}_X(x) =\begin{cases} \text{ibeta}(n/2, m/2, n/(n+mx)), & mx > n,\\ \text{ibetac}(m/2, n/2, mx/(n+mx)) & mx \le n. \end{cases}\end{split}\]Here \(\text{ibeta}(\cdot)\) denotes the real normalised incomplete beta function, and \(\text{ibetac}(\cdot)\) denotes the real normalised complementary incomplete beta function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; x = 3; >>> print (" sf: ", fisher_f(mu, sigma).pdf(x)) sf: 6.3563523462564525615615615614561356E-20
- dist_fisher_f.qtf(q)#
Returns \(\text{qtf}_X(x)\), the quantile function (qtf) of a random variable \(X\), following a central Fisher F distribution:
\[\text{qtf}_X(q) = \frac{nx}{m(1-x)}, \quad \text{where } x = \mathrm{ibeta\_inv}(m/2, n/2, q).\]Here \(\mathrm{ibeta\_inv}(\cdot)\) denotes the inverse of the real normalised incomplete beta function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("qtf: ", fisher_f(mu, sigma).qtf(q)) qtf: 6.3563523462564525615615615614561356E+00
- dist_fisher_f.isf(q)#
Returns \(\text{isf}_X(q)\), the inverse survival function (isf) of a random variable \(X\), following a central Fisher F distribution:
\[\text{isf}_X(q) = \frac{nx}{m(1-x)}, \quad \text{where } x = \mathrm{ibetac\_inv}(m/2, n/2, q).\]Here \(\mathrm{ibetac\_inv}(\cdot)\) denotes the inverse of the real normalised complementary incomplete beta function.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; q = 0.3; >>> print ("isf: ", fisher_f(mu, sigma).isf(q)) 6.3563523462564525615615615614561356E+00
- dist_fisher_f.c_x(t)#
Returns \(C_X(t)\), the characteristic function of a random variable \(X\), following a central Fisher F distribution:
\[C_X(t) = \int_{0}^{\infty} e^{i tx} \text{pdf}_X(x) \mathrm{d} x = \frac{\Gamma(m/2+n/2)}{\Gamma(n/2)} U \left( \frac{m}{2}, 1-\frac{n}{2}, -\frac{n}{m} it \right)\]where \(U(\cdot)\) denotes the confluent hypergeometric function of the second kind.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; >>> print ("c_x: ", fisher_f(mu, sigma).c_x(t)) 6.3563523462564525615615615614561356E+00
- dist_fisher_f.m_x(t)#
Returns
NaN, since the moment generating function does not exist.
- dist_fisher_f.k_x(t, k=0)#
Returns
NaN, since the cumulant generating function does not exist.
- dist_fisher_f.moments(k)#
Returns the first \(j\) raw moments, \(\mu_j, j = 1 \ldots k\), of a random variable \(X\), following a central Fisher F distribution. The rth moments only exists for \(n_2 > 2r\).
\[\mu'_X(r) = \mu'_{F}(r)= \frac{\Gamma( \tfrac{1}{2}n_1+r)-\Gamma( \tfrac{1}{2}n_2-r)}{\Gamma( \tfrac{1}{2}n_2)}, \quad \text{for } n_2 > 2r.\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", fisher_f(mu, sigma).moments(k)) 6.3563523462564525615615615614561356E+00
- dist_fisher_f.cumulants(k)#
Returns the first \(j\) cumulants, \(\kappa_j, j = 1 \ldots k\), of a random variable \(X\), following a central Fisher F distribution. The cumulants are calculated from the moments.
>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; k = 6; >>> print ("saddlepoint: ", fisher_f(mu, sigma).cumulants(k)) 6.3563523462564525615615615614561356E+00
Additional methods: Recurrence relations
Let the density \(g_{m,n}\) be that of \(m/n\) times an \(F_{m,n}\) random variable. Let \(G_{m,n}(y)\) be its distribution function.
Then the following recurrence relations hold (see Chattamvelli, 1995)
- dist_fisher_f.recurrence_pdf(x, lambda, start_n1, start_n2, target_n1, target_n2)#
Applies a recurrence relation to calculate the cdf for different degrees of freedom for a given value of x. This is mostly useful when using asymptotic methods.
\[n\left[G_{m,n+2}(y)-G_{m-2,n+2}(y)\right] = -2g_{m,n}(y)\]\[m(1+y)]g_{m+2,n}(y) + y(m+n)g_{m,n}(y).\]\[n(1+y) g_{m,n+2}(y) = (m+n)g_{m,n}(y).\]\[m g_{m+2,n-2}(y) = (n-2) y g_{m,n}(y).\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; k = 6; >>> print ("c_x: ", fisher_f(mu, sigma).k_x(t, k)) 6.3563523462564525615615615614561356E+00
- dist_fisher_f.recurrence_cdf(x, lambda, start_n1, start_n2, target_n1, target_n2)#
Applies a recurrence relation to calculate the cdf for different degrees of freedom for a given value of x. This is mostly useful when using asymptotic methods.
From these equations we obtain
\begin{eqnarray} [(m+2)(1+y)]G_{m+4,n}(y) & = & [(m+2)(1+y)+y(m+n]G_{m+2,n}(y) \\ & - & y(m+n)G_{m,n}(y) \nonumber \end{eqnarray}\[n(1+y) :cite:t:`G_{m,n+2}(y)-G_{m+2,n+2}(y)] = (m+n) :cite:t:`G_{m,n}(y) - G_{m+2,n}(y)]\]\[(m+2) :cite:t:`G_{m+2,n}(y)-G_{m+4,n-2}(y)] = (n-2) :cite:t:`G_{m,n}(y) - G_{m+2,n}(y)]\]>>> from mpfunlab import * >>> mp.dps = 30 >>> mu = 0; sigma = 1; t = 0.3; k = 6; >>> print ("c_x: ", fisher_f(mu, sigma).k_x(t, k)) 6.3563523462564525615615615614561356E+00