gamma() public static method

For postive integers: Γ(n) = (n - 1)! For half integers: _ (2n)! Γ(½ + n) = √π ------- 4ⁿ n! For real numbers: use Lanczos approximation
public static gamma ( number $n ) : number
$n number
return number
Esempio n. 1
0
 /**
  * Probability density function
  *
  *     / ν + 1 \
  *  Γ |  -----  |
  *     \   2   /    /    x² \ ⁻⁽ᵛ⁺¹⁾/²
  *  -------------  | 1 + --  |
  *   __    / ν \    \    ν  /
  *  √νπ Γ |  -  |
  *         \ 2 /
  *
  *
  * @param number $x percentile
  * @param int    $ν degrees of freedom > 0
  */
 public static function PDF($x, int $ν)
 {
     Support::checkLimits(self::LIMITS, ['x' => $x, 'ν' => $ν]);
     $π = \M_PI;
     // Numerator
     $Γ⟮⟮ν+1⟯∕2⟯ = Special::gamma(($ν + 1) / 2);
     $⟮1+x²∕ν⟯ = 1 + $x ** 2 / $ν;
     $−⟮ν+1⟯∕2 = -($ν + 1) / 2;
     // Denominator
     $√⟮νπ⟯ = sqrt($ν * $π);
     $Γ⟮ν∕2⟯ = Special::gamma($ν / 2);
     return $Γ⟮⟮ν+1⟯∕2⟯ * $⟮1+x²∕ν⟯ ** $−⟮ν+1⟯∕2 / ($√⟮νπ⟯ * $Γ⟮ν∕2⟯);
 }
Esempio n. 2
0
 /**
  * Mean of the distribution
  *            _
  *           /ν Γ((ν - 1)/2)
  * E[T] = μ / - ------------    if ν > 1
  *         √  2    Γ(ν/2)
  *
  *      = Does not exist        if ν ≤ 1
  *
  * @param int    $ν Degrees of freedom
  * @param number $μ Noncentrality parameter
  *
  * @return number
  */
 public static function mean(int $ν, $μ)
 {
     Support::checkLimits(self::LIMITS, ['ν' => $ν, 'μ' => $μ]);
     if ($ν == 1) {
         return \NAN;
     }
     return $μ * sqrt($ν / 2) * Special::gamma(($ν - 1) / 2) / Special::gamma($ν / 2);
 }
Esempio n. 3
0
 /**
  * Mean of the distribution
  *
  * μ = λΓ(1 + 1/k)
  *
  * @param number $k shape parameter
  * @param number $λ scale parameter
  *
  * @return number
  */
 public static function mean($k, $λ)
 {
     Support::checkLimits(self::LIMITS, ['k' => $k, 'λ' => $λ]);
     return $λ * Special::gamma(1 + 1 / $k);
 }