Question: When playing Lets Make A Deal game, the contestants would nodoubt prefer to win a car than a goat. Lets use Matlab to testwhether it

When playing “Let’s Make A Deal” game, the contestants would nodoubt

prefer to win a car than a goat. Let’s use Matlab to testwhether it is more advantageous,

from a probabilistic standpoint, to stay with the first door orto switch to a different door

which Monty didn’t open.

(a) (3 pts) Write a Matlab function montyhall_stay thatimplements a single round of

the “Let’s Make A Deal” game where the contestant sticks withtheir original door. Your

function should pick the contestant’s door (for simplicity, youmay always choose door 1),

and uses your randnum() function to choose which door the car isbehind. If the car door

matches the contestant’s door your function should return 1(logical true), otherwise it

should return 0 (logical false).

(b) (5 pts) Write a Matlab function montyhall_switch thatimplements a single round of

the ”Let’s Make A Deal” game where the contestant switches theirdoor. Your function

should pick the original contestant’s door (for simplicity, youmay always choose door 1),

and use your randnum() function to choose which door the car isbehind. It should then

choose which door Monty Hall shows the contestant (yourrandnum_reject() function

will be useful here). Remember, he won’t show the door thecontestant picked or the door

the car is behind. Then, your function should choose thecontestant’s final door (which

will not be the original door or the door Monty shows them). Ifthe car door matches the

contestant’s final door your function should return 1, otherwiseit should return 0.

(c) (4 pts) Write a Matlab m-file montyhall_montecarlo.m thatdetermines the proba- bility of winning using each of the twostrategies. Your program should simulate 100,000 different randomrealizations of the game using each different strategy (200,000simula- tions in all). Your code should be general enough to workfor n doors, where you specify n within the m-file. For eachrealization, there is a probability of 1/n that the car is behindDoor 1, a probability of 1/n that the car is behind Door 2, etc.for every door. Keep track of how many times you win for eachstrategy. The estimate for the probability that you win the car fora given strategy is equal to the number of times you won divided bythe total number of tries. Your program’s output should be clearenough that we can tell which probability corresponds to the ”staystrategy” and which corresponds to the ”switch strategy”. Doingsimulations like this to estimate probabilities is known as theMonte Carlo method. Please turn in code with n=4.

Step by Step Solution

3.33 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below a function result montyhallstayn MONTYHALLSTAY Implements a single round of the Lets Make ... View full answer

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!