%%% *****************************************
%%% The MONTE HALL Problem
%%%
%%% Author: James Beck
%%% Date: Dec 2, 2006
%%% *****************************************
% THE QUESTION
% Say you're on a game show where they have three doors.
% One door has a car behind it, and the other two of the
% doors have goats. You randomly choose a door and the
% host opens one of the OTHER doors, and shows you that
% there is a goat behind it. Then he says, 'Do you want
% to pick the third door, or do you want to keep your
% origional choice?'. What do you pick and why?
% Number of times the situation is repeated
% -------------------------------------------
runs = 100000;
% SOLVE
% -------------------------------------------
% Carry out the situation over and over, and
% keep track of the results.
picked = 0;
for j=1:runs,
% Randomly pick a door for the car to be in
doors = [0,0,0];
[j,i] = max(rand(1,3));
doors(i) = 1;
% Randomly pick a door to go first
[j,pick] = max(rand(1,3));
% If the door you picked has the car, add one to the counter
if doors(pick)==1,
picked = picked + 1;
end
end
% DISPLAY STATISTICS/RESULTS
% -------------------------------------------
disp('---------------------------------------');
disp(['First Pick has the car: ',num2str(picked)]);
disp(['The other door has the car: ',num2str(runs-picked)]);
disp('---------------------------------------');
disp(['The ratios are: [',num2str(picked/runs),'] (picked) and [',num2str((runs-picked)/runs),'] (the other).']);