code in python (A) please   Solve the so-called "Birthday Problem". Write a program that takes an integer ?N and uses the function np.random.randint (low = 0, high = N) from numpy to generate a random sequence of integers between 00 and ?−1N−1. Run experiments to validate the hypothesis that the number of integers generated until the first repeated value is approximately ?∗?2⎯⎯⎯⎯⎯⎯⎯√π∗N2. a) Write a function birthday(N) that returns the number of values generated until a value is repeated as a function of the range of possible values ?N (from 00 to ?−1N−1); b) Write a function birthday_sim(N) that repeats birthday(N) a total of n_sim = 20000 times and returns the average of all the numbers generated; c) Show on one plot that as ?N increases (with a doubl

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 11E: (Numerical) a. The following is an extremely useful programming algorithm for rounding a real number...
icon
Related questions
Question

code in python

(A) please

 

Solve the so-called "Birthday Problem". Write a program that takes an integer ?N and uses the function np.random.randint (low = 0, high = N) from numpy to generate a random sequence of integers between 00 and ?−1N−1. Run experiments to validate the hypothesis that the number of integers generated until the first repeated value is approximately ?∗?2⎯⎯⎯⎯⎯⎯⎯√π∗N2.

a) Write a function birthday(N) that returns the number of values generated until a value is repeated as a function of the range of possible values ?N (from 00 to ?−1N−1);

b) Write a function birthday_sim(N) that repeats birthday(N) a total of n_sim = 20000 times and returns the average of all the numbers generated;

c) Show on one plot that as ?N increases (with a doubling experiment), from ?=2N=2 to ?=1000N=1000, the value of birthday_sim(N) approaches ?∗?2⎯⎯⎯⎯⎯⎯⎯√π∗N2.

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Returning value from Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr