Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Image: ubuntu2004
The Birthday Problem
Suppose that people are gathered in a room.
What are the odds that people in the room share the same birthday?
Estimate the probability that two out of people in a room share the same birthday, it is guaranteed that
The function takes one parameter, which is the number of people gathered in a room. An empty vector is appended to add number of random integers from (with replacement), which is the number of days of the year in which an individual's birthday can fall on, assuming we are not including leap years.
The function then compares each value in the vector. If any two or more of the values match (i.e, a 'shared birthday'), the boolean value returns , else, it returns .
The function takes two parameters, the number of repeated which will be conducted (the larger this number is the more accurate the estimated probability will be), and the number of people in the room. Each loop calls upon the function . If has returned , a counter variable increases by . The function then returns the cumulative which is calculated as the .
I have estimated the probability of or more out of people sharing a birthday is .