一个简单的泊松分布函数,它只对较小的数字有效(对于大多数系统,最大值约为 ~100/100)
<?php
function factorial($number)
{
if ($number < 2) {
return 1;
} else {
return ($number * factorial($number-1));
}
}
function poisson($chance, $occurrence)
{
$e = exp(1);
$a = pow($e, (-1 * $chance));
$b = pow($chance,$occurrence);
$c = factorial($occurrence);
return $a * $b / $c;
}
$test = poisson(100,100);
echo $test . "\n";
?>