Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please follow the steps that were given. USE PYTHON ONLY. (Birthday Problem) Suppose that people enter an empty room until a pair of people share

Please follow the steps that were given. USE PYTHON ONLY.

(Birthday Problem) 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 trial 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).

$ python3 birthday. py 1000

24

image text in transcribedimage text in transcribed

birthday.py (/coursework/homework4) File Edit View Search Tools Documents Help # 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. trials = # Define a variable count denoting the total number of individuals sampled # across the trials number of experiments, and initialize it to cound = # Peform trials number of experiments, where each experiment involves sampling # individuals until a pair of them share a birthday. for t in range(.. .): # Setup a 1D list birthdays seen of DAYS-PER-YEAR booleans, all set to # False by default. This list will keep track of the birthdays encountered # in this experiment. birthdays-seen -... # Sample individuals until match. while...: # Increment count by 1 Python Tab Width: 4 Ln 21, Col 32 INS homework4 - File Manager birthday.py (/coursewor.... |-1) 3:20 pm birthday.py (/coursework/homework4) File Edit View Search Tools Documents Help # 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. trials = # Define a variable count denoting the total number of individuals sampled # across the trials number of experiments, and initialize it to cound = # Peform trials number of experiments, where each experiment involves sampling # individuals until a pair of them share a birthday. for t in range(.. .): # Setup a 1D list birthdays seen of DAYS-PER-YEAR booleans, all set to # False by default. This list will keep track of the birthdays encountered # in this experiment. birthdays-seen -... # Sample individuals until match. while...: # Increment count by 1 Python Tab Width: 4 Ln 21, Col 32 INS homework4 - File Manager birthday.py (/coursewor.... |-1) 3:20 pm

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions