I have zero knowledge of scientific probability so it may be just me, but on a purely common-sense level the result of this script feels completely counter-intuitive:
If there are 365 possible unique birth dates and there are 90 people in the room (i.e. 1/4 of the number of unique birthdates), how can the probability of two of them having the same birthday be “nearly 100%”?
Moreover, why does the script return an error if I enter a number of people higher than 120?
When there are 23 people in a room, the probability of two having the same birthday is roughly 0.5. That number goes up quickly as more and more people enter the room. With 90 people in the room the chance of no two having the same birthday is very small, about 0.00002. So the probability that at least two people have the same birthday is 1 - 0.00002 which is still very close to 1.
I was wondering, in the code for this exercise the “simulate” function comes earlier in the code than the “calculate_probability” and the “find_duplicates” functions even though “simulate” uses these functions in its body. Does python care about the order of the function definitions in its code?
It is fine for func_one to include a call to func_two, even though func_two was not yet defined, so long as func_two gets defined before that calling statement actually executes.
Neither of the above functions executes until this statement calls func_one:
print(func_one(4))
Therefore, by the time the statement in func_one that calls func_two gets executed, func_two has been defined.
By contrast, this raises a NameError because the call to func_two attempts to execute before func_two has been defined:
Is it possible that this calculation is a bit wrong?
Because the possibility that a day in february is choosen is as high as a month in in june is choosen.
There are 28 days in February (29 in a leap year) and 30 days in June. Therefore, the probability of choosing a certain day in February is 1/28 or 1/29, while the probability of choosing a certain day in June is lower, 1/30.
if birthdays_list[i] == birthday and i != index:
people.append(i + 1)
if people:
people.append(index + 1)
print("\n\nIn our simulation, the following people have the same birthdays: ")
for person in people:
print("Person {0}".format(person))
return True
else:
return False
i can’t understand what they did to match the same bday from the list
When I played around with the numbers of people in the room, it wasn’t until there were 83 people in the room that I got 100% chance of 2 of them having the same birthday.
In my life, I have only ever met 1 other person with the same birthday. So I am unlikely to be the person with a matching birthday. Just saying!
One sensible thing that I will say, is that results tend to be easily believed, and rely on someone understanding the problem sufficiently to code it.
The exercise is to keep changing the number to see the probable results. How do I move on from this step? I found the numbers that give me nearly 100% probability however I cannot advance to the next lesson. Am I missing something?
Aye Aye So On The Exercise INTRODUCTION TO DATA SCIENCE. Probability .
First I Thought: num_people_in_room = 366
Because There are 365 days in a year so That
each day of a year May be assigned To One person.
with one Extra Person So That The Number Is 366
Not 365. Because 366 Is A Luckier Prettier And Funner Number Then 365.
Tho At num_people_in_room = 366
overflowError: int too large to convert to float.
So I try 366/2=183
num_people_in_room = 183
overflowError: int too large to convert to float
So I try 366/3=122
num_people_in_room=122
overflowError: int too large to convert to float
So I try 366/4=91.5
num_people_in_room=93
Again 93 instead of 91 or 92
because 3 is a prime factor of 9
93 also may imply triple nines.
At num_people_in_room=93
Person 92’s Birthday: June 9
Person 93’s Birthday: November 15
The probablity that two people
in a room of 93 have the
same birthday is nearly 100.0%
In our simulation, the following
people have the same birthdays:
person 28
person 7
It Is Interesting how that 93 is Nearly 366/4
so that 93 is approximately one fourth of 366
And That in The simulation persons 28 and 7
have the same birthday.
because of 7 being one fourth of 28
I Wonder At the Raw mathematics of This simulation.
due to the limitation in range I’m inferring that this simulation
is based on a parabola of a quadratic function.
with out even running
num_people_in_room=100
I Infer based on
num_people_in_room=93
being the first Number I changed
that worked after first 183 second 122 third 93
That The range Of The Parabola is
2 < X < 98 Or 2 < X < 100
Lastly On my First reflection of this Learn.
I Say that the second time I run
num_people_in_room=93
person 24 and person 3 have the same birthday.
8 times 3 is 24.
so that in each result
one of the persons was
defined by a number
that is a prime factor of the other
persons number.
If that this smulation is in fact based on a parabola
the range of that parabola does seem to be 2 ≤ X ≤ 120
because any Change of number greater then 120
overflowError: int too large to convert to float