MathPHP\Probability\Distribution\Discrete\Binomial::PMF PHP Method

PMF() public static method

P(X = r) = nCr pʳ (1 - p)ⁿ⁻ʳ
public static PMF ( integer $n, integer $r, float $p ) : float
$n integer number of events
$r integer number of successful events
$p float probability of success
return float
    public static function PMF(int $n, int $r, float $p) : float
    {
        Support::checkLimits(self::LIMITS, ['n' => $n, 'r' => $r, 'p' => $p]);
        $nCr = Combinatorics::combinations($n, $r);
        $pʳ = pow($p, $r);
        $⟮1 − p⟯ⁿ⁻ʳ = pow(1 - $p, $n - $r);
        return $nCr * $pʳ * $⟮1 − p⟯ⁿ⁻ʳ;
    }
Binomial