Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Birthday problem - in javascript \o/ cf http://en.wikipedia.org/wiki/Birthday_problem
// PARADOX ! Inception-style
var paradox = function(setSize,p){
Math.sqrt(2*setSize*Math.log(1/(1-p)))
};
// So that's the generic formula.
// Applied to the usual "over 50% of prob to have 2 people with the same birthday"
paradox(365, 0.5); // => 22.49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment