Created
August 14, 2018 14:22
-
-
Save esquinas/7afa813967fd6e2aace50e5fd8bd3c4d to your computer and use it in GitHub Desktop.
Calculate percentage probability of birthday collisions (Birthday paradox)
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
import math | |
def prob_of_birthday_collision(people=23.0, days=365.25): | |
e = math.e | |
k = float(people) | |
n = float(days) | |
return 100.0*(1.0-e**((-k*(k-1.0)) / (2.0*n))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment