https://en.wikipedia.org/wiki/Beta_function#Incomplete_beta_function
This function looks at the values of x, a, and b, and determines which algorithm is best to calculate
the value of Iₓ(a, b)
http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html
https://github.com/boostorg/math/blob/develop/include/boost/math/special_functions/beta.hpp
public static regularizedIncompleteBeta ( $x, $a, $b ) : number | ||
$x | Upper limit of the integration 0 ≦ x ≦ 1 | |
$a | Shape parameter a > 0 | |
$b | Shape parameter b > 0 | |
Résultat | number |
/** * Cumulative distribution function * Calculate the cumulative t value up to a point, left tail. * * cdf = 1 - ½Iₓ₍t₎(ν/2, ½) * * ν * where x(t) = ------ * t² + ν * * Iₓ₍t₎(ν/2, ½) is the regularized incomplete beta function * * @param number $t t score * @param int $ν degrees of freedom > 0 */ public static function CDF($t, int $ν) { Support::checkLimits(self::LIMITS, ['t' => $t, 'ν' => $ν]); if ($t == 0) { return 0.5; } $x⟮t⟯ = $ν / ($t ** 2 + $ν); $ν/2 = $ν / 2; $½ = 0.5; $Iₓ = Special::regularizedIncompleteBeta($x⟮t⟯, $ν/2, $½); if ($t < 0) { return $½ * $Iₓ; } // $t ≥ 0 return 1 - $½ * $Iₓ; }
/** * F used within CDF * _ _ * 1 ∞ | / 1 ν \ / ν \ | * Fᵥ,ᵤ(x) = Φ(-μ) + - ∑ | pⱼIy | j + -, - | + qⱼIy | j + 1, - | | * 2 ʲ⁼⁰ |_ \ 2 2 / \ 2 / _| * * where * Φ = cumulative distribution function of the standard normal distribution * Iy(a,b) = regularized incomplete beta function * * x² * y = ------ * x² + ν * * 1 / μ² \ / μ² \ʲ * pⱼ = -- exp| - - | | - | * j! \ 2 / \ 2 / * * μ / μ² \ / μ² \ʲ * qⱼ = ------------ exp| - - | | - | * √2Γ(j + 3/2) \ 2 / \ 2 / * * @param number $x * @param int $ν Degrees of freedom * @param number $μ Noncentrality parameter * * @return number */ private static function F($x, int $ν, $μ) { Support::checkLimits(self::LIMITS, ['x' => $x, 'ν' => $ν, 'μ' => $μ]); $Φ = StandardNormal::CDF(-$μ); $y = $x ** 2 / ($x ** 2 + $ν); $sum = $Φ; $tol = 1.0E-8; $j = 0; do { $exp = exp(-1 * $μ ** 2 / 2) * ($μ ** 2 / 2) ** $j; $pⱼ = 1 / Combinatorics::factorial($j) * $exp; $qⱼ = $μ / sqrt(2) / Special::gamma($j + 3 / 2) * $exp; $I1 = Special::regularizedIncompleteBeta($y, $j + 1 / 2, $ν / 2); $I2 = Special::regularizedIncompleteBeta($y, $j + 1, $ν / 2); $delta = $pⱼ * $I1 + $qⱼ * $I2; $sum += $delta / 2; $j += 1; } while ($delta / $sum > $tol || $j < 10); return $sum; }
/** * Cumulative distribution function * * cdf = Iₓ(α,β) * * @param number $α shape parameter α > 0 * @param number $β shape parameter β > 0 * @param number $x x ∈ (0,1) * * @return float */ public static function CDF($x, $α, $β) { Support::checkLimits(self::LIMITS, ['x' => $x, 'α' => $α, 'β' => $β]); return Special::regularizedIncompleteBeta($x, $α, $β); }
/** * Cumulative distribution function * * / d₁ d₂ \ * I | --, -- | * ᵈ¹ˣ \ 2 2 / * ------ * ᵈ¹ˣ⁺ᵈ² * * Where I is the regularized incomplete beta function. * * @param number $x percentile ≥ 0 * @param int $d₁ degree of freedom v1 > 0 * @param int $d₂ degree of freedom v2 > 0 * * @return number */ public static function CDF($x, int $d₁, int $d₂) { Support::checkLimits(self::LIMITS, ['x' => $x, 'd₁' => $d₁, 'd₂' => $d₂]); $ᵈ¹ˣ/d₁x+d₂ = $d₁ * $x / ($d₁ * $x + $d₂); return Special::regularizedIncompleteBeta($ᵈ¹ˣ/d₁x+d₂, $d₁ / 2, $d₂ / 2); }