Last active
December 15, 2015 05:58
-
-
Save echojc/5212393 to your computer and use it in GitHub Desktop.
Simple empirical test of birthday problem probabilities.
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
def bday = new Random().nextInt(365) | |
def uniq(n: Int) = (1 to n).map(_ => bday).distinct.size == n | |
def puniq(n: Int, c: Int = 1000000) = (1 to c).map(_ => uniq(n)).count(_ == true).toDouble / c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment