INSTRUCTIONS:
I NEED THE SOLUTION TO THE FOLLOWING QUESTION ON MATLAB SOFTWARE
CODE.
PROBLEMS#1
This problem is commonly known as the Monty Hall Problem and is
based on Bayes’ Theorem. In this problem suppose you're on a game
show, and you're given the choice of three doors: Behind one door
is a car; behind
the others, goats. You pick a door, say No. 1, and the host, who
knows what's behind the doors, opens another door, say No. 3, which
has a goat. He then says to you, "Do you want to pick door No. 2?"
Is it to your advantage to switch your choice?
As I mentioned, I need solution to this question via a MATLAB code
N=10000;%N number of trials
%Lets assume candidate always picks the door 1
DoorWithPrize=randi([1,3],N,1);%this is an N element array, where
each element is the door with prize
%when we never switch door
ProbabilityNotSwitching = sum(DoorWithPrize==1)/N;
%when we always switch
%in this case, we will win only when the prize door is not 1
ProbabilitySwitching = sum(DoorWithPrize~=1)/N;
fprintf('After %d trials:\nProbability of winning when not switching: %f\nProbability of winning when switching: %f\n',N,ProbabilityNotSwitching,ProbabilitySwitching)
Get Answers For Free
Most questions answered within 1 hours.