subject

The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have the same birthday? It is possible to determine the answer to this question via simulation. Using the starting template provided to you, complete the function called calc birthday probability that takes as input n and returns the probability that two or more of the n people will have the same birthday. To do this, the function should create a list of size n and generate n birthdays in the range 1 to 365 randomly, inclusive of the end-points 1 and 365. It should then check to see if any of the n birthdays are identical. The function should perform this experiment 106 times and calculate the fraction of time during which two or more people had the same birthday. The function will be called as follows from your main program

Import random

def calc_birthday_probability (num_people):
num_tries = le6
num_duplicates = 0

""" FIXME: Complete this function to return the probability of num_people in the room having the same birthday. """

return num_duplicates/num_tries
def main ():
num_people = 10
p = calc_birthday_probability (num_people)

num_people = 20
p = calc_birthday_probability (num_people)

return

# Main program
if __name__ == "_main_":
random. seed (2020)
main ()

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the can apple do to fix this issue?
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
1. for which of the following are you not required to signal beforehand? a. changing lanes b. speeding up c. stopping
Answers: 2
question
Computers and Technology, 24.06.2019 00:00
Consider the series where in this problem you must attempt to use the ratio test to decide whether the series converges. compute enter the numerical value of the limit l if it converges, inf if it diverges to infinity, minf if it diverges to negative infinity, or div if it diverges but not to infinity or negative infinity.
Answers: 1
question
Computers and Technology, 25.06.2019 00:00
What function key is used to enable the spelling and grammar function
Answers: 1
You know the right answer?
The birthday problem is as follows: given a group of n people in a room, what is the probability tha...
Questions
question
History, 19.08.2021 22:00
question
Mathematics, 19.08.2021 22:00
Questions on the website: 13722367