beta() public static method

https://en.wikipedia.org/wiki/Beta_function Γ(x)Γ(y) B(x, y) = -------- Γ(x + y)
public static beta ( integer $x, integer $y ) : float
$x integer
$y integer
return float
Beispiel #1
0
 /**
  * Probability density function
  *
  *       xᵃ⁻¹(1 - x)ᵝ⁻¹
  * pdf = --------------
  *           B(α,β)
  *
  * @param number $α shape parameter α > 0
  * @param number $β shape parameter β > 0
  * @param number $x x ∈ (0,1)
  *
  * @return float
  */
 public static function PDF($x, $α, $β)
 {
     Support::checkLimits(self::LIMITS, ['x' => $x, 'α' => $α, 'β' => $β]);
     $xᵃ⁻¹ = pow($x, $α - 1);
     $⟮1 − x⟯ᵝ⁻¹ = pow(1 - $x, $β - 1);
     $B⟮α、β⟯ = Special::beta($α, $β);
     return $xᵃ⁻¹ * $⟮1 − x⟯ᵝ⁻¹ / $B⟮α、β⟯;
 }
Beispiel #2
0
 /**
  * Probability density function
  *
  *      __________________
  *     / (d₁ x)ᵈ¹ d₂ᵈ²
  *    /  ----------------
  *   √   (d₁ x + d₂)ᵈ¹⁺ᵈ²
  *   ---------------------
  *           / d₁  d₂ \
  *      x B |  --, --  |
  *           \ 2   2  /
  *
  * @param number $x  percentile ≥ 0
  * @param int    $d₁ degree of freedom v1 > 0
  * @param int    $d₂ degree of freedom v2 > 0
  *
  * @todo how to handle x = 0
  *
  * @return number probability
  */
 public static function PDF($x, int $d₁, int $d₂)
 {
     Support::checkLimits(self::LIMITS, ['x' => $x, 'd₁' => $d₁, 'd₂' => $d₂]);
     // Numerator
     $⟮d₁x⟯ᵈ¹d₂ᵈ² = ($d₁ * $x) ** $d₁ * $d₂ ** $d₂;
     $⟮d₁x+d₂⟯ᵈ¹⁺ᵈ² = ($d₁ * $x + $d₂) ** ($d₁ + $d₂);
     $√⟮d₁x⟯ᵈ¹d₂ᵈ²/⟮d₁x+d₂⟯ᵈ¹⁺ᵈ² = sqrt($⟮d₁x⟯ᵈ¹d₂ᵈ² / $⟮d₁x+d₂⟯ᵈ¹⁺ᵈ²);
     // Denominator
     $xB⟮d₁/2、d₂/2⟯ = $x * Special::beta($d₁ / 2, $d₂ / 2);
     return $√⟮d₁x⟯ᵈ¹d₂ᵈ²/⟮d₁x+d₂⟯ᵈ¹⁺ᵈ² / $xB⟮d₁/2、d₂/2⟯;
 }