Last active
August 8, 2017 18:57
-
-
Save jorovipe97/3984b8251e736b256b4318c47d28c78e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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