In problem 1,
the solution to number of people needed such that probability of 2 people having same birthday comes out to be 254.
But in class the way it was solved it came out as 23.
What am I understanding incorrectly here?
In problem 1,
the solution to number of people needed such that probability of 2 people having same birthday comes out to be 254.
But in class the way it was solved it came out as 23.
What am I understanding incorrectly here?
Kindly verify this.
Okay I think what I misunderstood is:
In the class-
We found that if we have 23 people then there is >50% chance that atleast 2 people have same birthday.
We tried finding probability that NO ONE has same birthday among themselves.
In lab problem 1-
The situation of interest is that NO ONE has birthday as that of one specific student. BUT there may be 2 people who have same birthday (just not same as the one specific student).
Ex. If bday of specific student is 1 March then no other student has birthday on 1 March BUT there maybe 2 students who have birthday of (say) 1 Jan.
I also was somewhat confused by this, but but to make the lab problem_1 to match the lecture one would need to change it to problem_1_1
# before
def problem_1(n_students):
# Predefine a specific birthday
predef_bday = np.random.randint(0, 365)
# Generate birthdays for every student
gen_bdays = np.random.randint(0, 365, (n_students))
# print(predef_bday in gen_bdays, predef_bday, gen_bdays)
# Check if predefined bday is among students
return predef_bday in gen_bdays
# after
def problem_1_1(n_students):
# This is no longer relevant as we are looking at any two people and not one specific person
# # Predefine a specific birthday
# predef_bday = np.random.randint(0, 365)
# Generate birthdays for every student
gen_bdays = np.random.randint(0, 365, (n_students))
# check if any two people have same birthday
return len(gen_bdays) - len(np.unique(gen_bdays))