Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON ONLY! PLEASE FOLLOW STEPS GIVEN SO I CAN USE TO UNDERSTAND BETTER Suppose that people enter an empty room until a pair of people

image text in transcribedPYTHON ONLY! PLEASE FOLLOW STEPS GIVEN SO I CAN USE TO UNDERSTAND BETTER

Suppose that people enter an empty room until a pair of people share a birthday. On average, how many people will have to enter before there is a match? Write a program birthday.py that takes an integer trials from the command line and runs trials experiments to estimate this quantity, where each experiment involves sampling individuals until a pair of them share a birthday. Assume birthdays to be uniform random integers from the interval [0, 365). $ python birthday.py 1000 24 # birthday .py. estimates the number people that must be sampled until a # pair of them share a birthday, import random| import stdarray import stdio import sys DAYS_PER_YEAR = 365 # Get trials from command line, as an int. # Define a variable count denoting the total number of individuals sampled # across the trials number of experiments. # Perform trials number of experiments, where each experiment involves sampling a individuals until a pair of them share a birthday. for t in range(...): # Setup a ID list birthday s_seen of DAYS_PER_YEAR booleans, all set to a # False by default. This list will keep track of the birthdays encountered a # in this experiment. # Sample individuals until match. # while: # Increment count by 1. # Define a variable birthday with a random integer from the interval # [0, DAYS_PER_YEAR). # If birthday has been encountered, abort this experiment. # Record the fact that we are seeing this birthday for the first time. # Write the average number of people that must be sampled before a match. Suppose that people enter an empty room until a pair of people share a birthday. On average, how many people will have to enter before there is a match? Write a program birthday.py that takes an integer trials from the command line and runs trials experiments to estimate this quantity, where each experiment involves sampling individuals until a pair of them share a birthday. Assume birthdays to be uniform random integers from the interval [0, 365). $ python birthday.py 1000 24 # birthday .py. estimates the number people that must be sampled until a # pair of them share a birthday, import random| import stdarray import stdio import sys DAYS_PER_YEAR = 365 # Get trials from command line, as an int. # Define a variable count denoting the total number of individuals sampled # across the trials number of experiments. # Perform trials number of experiments, where each experiment involves sampling a individuals until a pair of them share a birthday. for t in range(...): # Setup a ID list birthday s_seen of DAYS_PER_YEAR booleans, all set to a # False by default. This list will keep track of the birthdays encountered a # in this experiment. # Sample individuals until match. # while: # Increment count by 1. # Define a variable birthday with a random integer from the interval # [0, DAYS_PER_YEAR). # If birthday has been encountered, abort this experiment. # Record the fact that we are seeing this birthday for the first time. # Write the average number of people that must be sampled before a match

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

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

Show that (x2 + 1) / (x + 1) is O(x).

Answered: 1 week ago

Question

2. Do you find change a. invigorating? b. stressful? _______

Answered: 1 week ago

Question

10. Are you a. a leader? b. a follower? _______

Answered: 1 week ago