Monty Hall Provide MATLAB code with any figures and graphs Consider a game show
ID: 3772161 • Letter: M
Question
Monty Hall
Provide MATLAB code with any figures and graphs
Consider a game show in which contestant is to choose among three doors, one of which conceals a new car, while the other two are empty. Regardless of the choice made, at least one of the remaining doors is empty. The show host opens one door to show it empty. The contestant is given the opportunity to switch doors. Should the contestant switch? To experimentally determine the contestant's best strategy, first conduct the experiment 100 time using the strategy of the contestant not changing his/her original choose. Then, conduct the experiment 100 times with the contestant changing his/her original chose when given the opportunity by the show host. Estimate the probabilities that the contestant wins the car using both strategies. Can you provide a theoritical reason for your results?Explanation / Answer
The Monty Hall problem is a well-known puzzle in probability derived from an American game show, Let’s Make a Deal. Intuition leads many people to get the puzzle wrong, and when the Monty Hall problem is presented in a newspaper or discussion list, it often leads to a lengthy argument in letters-to-the-editor and on message boards.
The game is played like this:
Algorithm
function MontyHall(numDoors,numSimulations)
assert(numDoors > 2);
function num = randInt(n)
num = floor( n*rand()+1 );
end
switchedDoors = [0 0];
stayed = [0 0];
for i = (1:numSimulations)
availableDoors = (1:numDoors);
winningDoor = randInt(numDoors);
playersOriginalChoice = randInt(numDoors);
availableDoors(playersOriginalChoice) = [];
%Pick the door to open from the available doors
openDoor = availableDoors(randperm(numel(availableDoors)));
openDoor(openDoor == winningDoor) = [];
openDoor = openDoor(randInt(numel(openDoor)));
availableDoors(availableDoors==openDoor) = []; %Remove the open door from the available doors
availableDoors(end+1) = playersOriginalChoice; %Put the player's original choice back into the pool of available doors
availableDoors = sort(availableDoors);
playersNewChoice = availableDoors(randInt(numel(availableDoors))); %Pick one of the available doors
if playersNewChoice == playersOriginalChoice
switch playersNewChoice == winningDoor
case true
stayed(1) = stayed(1) + 1;
case false
stayed(2) = stayed(2) + 1;
otherwise
error 'ERROR'
end
else
switch playersNewChoice == winningDoor
case true
switchedDoors(1) = switchedDoors(1) + 1;
case false
switchedDoors(2) = switchedDoors(2) + 1;
otherwise
error 'ERROR'
end
end
end
disp(sprintf('Switch win percentage: %f%% Stay win percentage: %f%% ', [switchedDoors(1)/sum(switchedDoors),stayed(1)/sum(stayed)] * 100));
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.