Skip to content

Instantly share code, notes, and snippets.

@esquinas
Created August 14, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esquinas/7afa813967fd6e2aace50e5fd8bd3c4d to your computer and use it in GitHub Desktop.
Save esquinas/7afa813967fd6e2aace50e5fd8bd3c4d to your computer and use it in GitHub Desktop.
Calculate percentage probability of birthday collisions (Birthday paradox)
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