Skip to content

jjggu97/Birthday-paradox-simulation

Repository files navigation

Birthday Paradox Simulation 🎂

This repository contains Python scripts to simulate and analyze the Birthday Paradox.

The Birthday Paradox refers to the counterintuitive probability that in a group of

relatively few people, it's likely that at least two individuals share the same birthday.

birthday_paradox_simulation.py

This script calculates the theoretical probability of the Birthday Paradox based on mathematical formulas.

It takes the number of people as input and outputs the calculated probability.


How to use

Run the script and input the number of people when prompted.

The script will run simulations and plot the probability of a birthday match for different group sizes.


birthday_paradox_visualization.py

This script simulates the Birthday Paradox through random simulations.

It generates random birthdays for a specified number of people and checks if there are any shared birthdays.

The script outputs the probability of a birthday match based on the simulations.


How to use

Run the script, and it will run simulations and plot the probability of a birthday match for different group sizes.


Visualization

The script includes a visualization of the simulation results using Matplotlib.

The x-axis represents the number of people in the group, and the y-axis represents the probability of a birthday match.

result


Conclusion

Through this script, we confirmed the high probability of people sharing the same birthday.

For example, when 23 people get together, the chance of shared birthdays goes over 50%.

We can see that the probability of sharing the same birthday is higher than what our intuition would suggest.

References