Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using the template code with the given variables, solve the birthday probability paradox. import random def do_birthday_simula 1.(N, M, a_seed): random.seed (a_seed) num_hits = 0

using the template code with the given variables, solve the birthday probability paradox. image text in transcribed
image text in transcribed
import random def do_birthday_simula 1.(N, M, a_seed): random.seed (a_seed) num_hits = 0 run M simulations and increment num_hits for each one that is a hit " for i in range (M) : This statement generates the N random birthdays birthdays - (random.randint(1,365) for j in range (N) ) Your code goes here" VII if name N = return num_hits / M main 25 M = 100 a_seed - 1972227 print ('For [:d) simulations of groups of (:d) people with seed (:d), the probability of a common birthday is 1:.2)'.format (N,M, a_seed, do birthday_simulation (N, M, a_seed) >> 6.39 Programming Project 1: Probability of Common Birthdays Given a group of people, what is the probability that at least one day of the year is the birthday of two or more members of the group? In this assignment, we will use simulations of groups of people with randomly assigned birthdays to find out The program template given below, my_birthday.py, defines the function do_birthday_simulation() which has three arguments. Nis the number of people, Mis the number of simulation trials to perform and a seed is the seed for the pseudorandom number generator Note that the statement birthdays - [random.randint(1,365) for j in range (N) 1 assigns a random integer between 1 and 365 inclusive to each of elements of a list called birthdays Complete the function definition so that it returns True if at least one of those integers appears two or more times in the list The _main_block is provided in the template so that you can run your program locally on your own computer for testing. It does not matter what the __main_block contains when you submit you will only be graded on the performance of your do_birthday_simulation () function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

=+what kinds of policies and practices should be developed?

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago