According to the Birthday Problem, if birthdays are uniformly distributed across a 365-day year, a group of just 23 people has approximately a 50.7% chance of at least one shared birthday.
Generate a list of all possible days in a non-leap year:
In[1]:=
aYear=DayRange[{2007,1,1},{2007,12,31}];
Format the output to display only the month and day, removing the year:
Count occurrences of groups with and without shared birthdays:
In[5]:=
counts=Counts[results]
Out[5]=
1507073,0492927
Calculate the probability of shared birthdays across groups:
In[6]:=
probability=N[counts[1]/Total[counts]]
Out[6]=
0.507073
Create a histogram to visualize the result:
In[7]:=
Histogramresults,
Out[7]=
The simulation confirms the result of the Birthday Problem: in a million random groups of 23 people, approximately 50.7% of the groups had at least one shared birthday, closely matching the theoretical probability.