/**
* Binomial distribution - probability mass function
* https://en.wikipedia.org/wiki/Binomial_distribution
*
* P(X = r) = nCr pʳ (1 - p)ⁿ⁻ʳ
*
* @param int $n number of events
* @param int $r number of successful events
* @param float $p 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⟯ⁿ⁻ʳ;
}