Skip to content

Instantly share code, notes, and snippets.

@jorovipe97
Last active August 8, 2017 18:57
Show Gist options
  • Save jorovipe97/3984b8251e736b256b4318c47d28c78e to your computer and use it in GitHub Desktop.
Save jorovipe97/3984b8251e736b256b4318c47d28c78e to your computer and use it in GitHub Desktop.
function sFact(num)
{
var rval=1;
for (var i = 2; i <= num; i++)
rval = rval * i;
return rval;
}
function poisson(k, lambda) {
return (Math.exp(-1*lambda) * Math.pow(lambda, k))/sFact(k);
}
function poissondist(min, max, lambda) {
for (var i = min; i <= max; i++) {
console.log("p(" + i + ", " + lambda + ") = " + poisson(i, lambda) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment