Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/woctezuma/consecutive-birthdays-probability
Probability that at least two people in a group are born on two consecutive days
https://github.com/woctezuma/consecutive-birthdays-probability
birthday birthdays consecutive probability stackoverflow-questions
Last synced: about 1 month ago
JSON representation
Probability that at least two people in a group are born on two consecutive days
- Host: GitHub
- URL: https://github.com/woctezuma/consecutive-birthdays-probability
- Owner: woctezuma
- License: mit
- Created: 2011-01-20T18:20:06.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2024-12-02T21:26:00.000Z (about 1 month ago)
- Last Synced: 2024-12-02T22:27:24.258Z (about 1 month ago)
- Topics: birthday, birthdays, consecutive, probability, stackoverflow-questions
- Language: Python
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Consecutive birthdays probability
[![Build status][Build image]][Build]
[![Code coverage][Codecov image]][Codecov][Build]:
[Build image]:[PyUp]: https://pyup.io/repos/github/woctezuma/Consecutive-birthdays-probability/
[Dependency image]: https://pyup.io/repos/github/woctezuma/Consecutive-birthdays-probability/shield.svg
[Python3 image]: https://pyup.io/repos/github/woctezuma/Consecutive-birthdays-probability/python-3-shield.svg[Codecov]: https://codecov.io/gh/woctezuma/Consecutive-birthdays-probability
[Codecov image]: https://codecov.io/gh/woctezuma/Consecutive-birthdays-probability/branch/master/graph/badge.svgLet n be a number of people. At least two of them may be born on the same day of the year with probability:
> 1 − ∏_{i=0}^{n−1} (365−i)/365
But what is the probability that at least two of them are born on two consecutive days of the year (considering December
31st and January 1st also consecutive)? Simulating pseudo-random integers with Python, we get a 99%-confidence interval
for any number of people. It seems a good approximation is:> (1 − (n−1)(2×365+n−1)) × (1 − ∏_{i=0}^{n−1} (365−2*i)/365)
Here is the correct formula:
> 1 − ∑_{k=1}^{n} 1/((365^(n−k))*k) × (∏_{i=1}^{k−1} (365−(k+i))/(365×i)) × (∑_{j=0}^{k−1}(−1)^j C_j^k (k−j)^n)
An explanation can be found [here](http://math.stackexchange.com/questions/18268/consecutive-birthdays-probability/18363#18363).