Question: Exercise 7 . 2 7 - The Birthday Problem Make a function BirthdayProblem.m with the declaration function p = BirthdayProblem ( n ) where n

Exercise 7.27- The Birthday Problem
Make a function BirthdayProblem.m with the declaration
function p= BirthdayProblem(n)
where n is a number of people and p is a probability vector. You can find the details of the Birthday Problem in the
textbook, but I am making the following modifications to the instructions:
The Birthday Problem primary function will create an (n-1)-vector of probabilities and a plot of those probabilities versus
n. You will perform a numerical experiment (described in the problem's hint) in a subfunction that your primary
function calls.
So if I input
p= BirthdayProblem(40)
p should be a vector of length n-1 that holds the probabilities of 2,3,4,dots,40 people sharing a birthday and your
program should create a plot of these probabilities. Inside your program, each of these individual probabilities should
be calculated by calling a subfunction that runs the numerical experiment for a given value of people. Use a loop call
the subfunction to do the experiment n-1 times.
7.27 The Birthday Problem The Birthday Problem is as follows: If there are 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 by simulation. Write a
function that calculates the probability that two or more of n people will have the same
birthday, where n is a calling argument. (Hint: To do this, the function should create an
array of size n and generate n birthdays in the range 1 to 365 randomly. It should then
check to see if any of the n birthdays are identical. The function should perform this
experiment at least 5000 times and calculate the fraction of those times in which two or
more people had the same birthday.) Write a test program that calculates and prints out
the probability that 2 or more of n people will have the same birthday for n=2,3,dots,40.
Exercise 7 . 2 7 - The Birthday Problem Make a

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!