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:

IN PYTHON PLEASE

import random

def calc_birthday_probability (num_people):

random. seed (2020) # Don't change this value

num_trials = 1000

probability = 0
""" FIXME: Complete this function to return the probability of two or more people in the room having the same birthday. """

return probability

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:00, dramaqueenactr2040
Two technicians are discussing the common u-joint. technician a says its input and output speeds should be equal. technician b says that it normally has two yokes. which technician is correct?
Answers: 1
image
Computers and Technology, 22.06.2019 08:00, wgdelgado
What is the first step in creating a maintenance ?
Answers: 2
image
Computers and Technology, 23.06.2019 17:00, kyleemarie2003
Companies that implement and apply an information system effectively can create
Answers: 1
image
Computers and Technology, 23.06.2019 22:30, delawdermia27
The output voltage of a power supply is assumed to be normally distributed. sixteen observations are taken at random on voltage are as follows: 10.35, 9.30, 10.00, 9.96, 11.65, 12.00, 11.25, 9.58, 11.54, 9.95, 10.28, 8.37, 10.44, 9.25, 9.38, and 10.85
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 in other subjects:

Konu
Mathematics, 05.05.2020 23:24
Konu
History, 05.05.2020 23:24