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, 22.06.2019 19:30
Singing in the rain: this first part of the film shows the early history of motion picture. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theater productions? explain.
Answers: 1
question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
question
Computers and Technology, 24.06.2019 12:30
Why does the pc send out a broadcast arp prior
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
Mathematics, 31.03.2021 17:40
question
Mathematics, 31.03.2021 17:40
question
Mathematics, 31.03.2021 17:40
question
French, 31.03.2021 17:40
Questions on the website: 13722360