Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are 50 students in a classroom. (a) What is the probability that there is

ID: 3027563 • Letter: T

Question

There are 50 students in a classroom.

(a) What is the probability that there is at least one pair of students having the same birthday? Show your steps.

(b) Write a MATLAB program to simulate the event, and verify your answer in (a). Hint: You probably need to repeat the simulation for many times to obtain a probability. Submit your code and result. (Need help mainly with the MATLAB code)

You may assume that a year only has 365 days. You may also assume that all days have equal likelihood to be taken.

(Need help mainly with the MATLAB code)

Explanation / Answer

Considering 365 days in a year ( avoiding leap year ) and two people in a group, the first person can have any birthday which gives him 365 possible birthdays out of 365 days. The chance that a second person has the same birthday is 1/365. Hence the probability that both people have same birthday, = (365/365) * (1/365) = 1/365. As the no of people n increases the complexity increases. That is where the basic rule of probability is to be utilized, ie. the probability that an event will happen + the probability that the event won't happen = 100% = 1.

Which implies

P(atleast 2 people share same birthday) + P(no 2 people share birthday) = 1
P(atleast 2 people share same birthday) = 1 - P(none share birthday).

In a group of 3, to find the probability that no two people will share a birthday -The first person can have any birthday ie 365 possibilities, the second person's birthday has to be different and hence probability is 364/365. That leaves 363 possibilities for the third person.

Hence probability that no two people will share a birthday =

(365/365) * (364/365) * (363/365)

Generalizing, the probability that n people have different birthdays is

((365-1)/365) * ((365-2)/365) * ((365-3)/365) * . . . * ((365-n+1)/365) =365Pn/365^n

Thus, the probability that 50 people have different birthdays is

((365-1)/365) * ((365-2)/365) * ((365-3)/365) * . . . * ((316)/365)

= 365P50/365^50= 0.03

P(atleast 2 people share same birthday) = 1 - P(none share birthday).

=1-0.03 =0.97

n=50;
no_samples=10000;
bday=ceil(365*rand(n, no_samples));
c=0;
for i=1: no_samples
if numel(bday(:,i))-numel(unique(bday(:,i))) >0
c=c+1;
end
end
probability=1-count/ no_samples