Skip to content

Instantly share code, notes, and snippets.

@anrieff
anrieff / birthdays.py
Last active April 29, 2018 20:05
Extended birthday problem: probability of M people sharing a birthday out of a group of N.
#!/usr/bin/python
""" Compute the probability of M people sharing a birthday out of a group of
N people.
The parameter `exact' determines whether we want to ignore clusterings of
more than M people with the same birthday (thus the largest group of
coincident birthdays is exactly M). If it's false, we allow "M or more".
How it works: we define a recursive counting function