Monty Hall Paradox

Manipulate[SeedRandom[IntegerPart[s]];oc=RandomChoice[{1,2,3},n];wd=RandomChoice[{1,2,3},n];pd=Table[RandomChoice[Complement[{1,2,3},{oc[[x]], wd[[x]]}]],{x,1,n}];nsw = Table[If[oc[[x]]==wd[[x]],1,0], {x,1,n}];sw = Table[If[Complement[{1,2,3},{oc[[x]], pd[[x]]}][[1]]==wd[[x]],1,0], {x,1,n}];ListPlot[{Accumulate[nsw], Accumulate[sw]}, PlotRange->{{0,n},{0,(2/3)n}}, Joined->True, PlotStyle->{Red, RGBColor[0,0.5,0]}, PlotLabel->Column[{"chance of winning without switching = " <>ToString[NumberForm[N[Total[nsw]/n],{4,3}]],"chance of winning with switching = " <>ToString[NumberForm[N[Total[sw]/n],{4,3}]]}], AxesLabel->{"trials", "wins"}, ImageSize->{500,375},ImagePadding->{{25,35},{25,60}}],
{{n,750, "number of trials"},10,1000,1,Appearance->"Labeled"},
{{s,256,"random seed"},1,1000,1,Appearance->"Labeled"},TrackedSymbols:>Manipulate]

CAPTION

On the old game show "Let's Make A Deal", hosted by Monty Hall, one particular game has a contestant presented with three doors. Behind one door is a fabulous prize, while the other two contain nothing. The contestant chooses a door. Monty Hall then opens one of the doors which has nothing behind it and asks the contestant if he or she would like to switch his or her choice of doors. It seems intuitive that it does not matter what the contestant chooses. However, taking the option to switch doubles the contestant's chance of winning. This Demonstration repeatedly plays the game, tallying wins and losses considering both cases of switching or not switching. In the long run it is obvious that, in fact, switching doors does improve the chances of winning.

THIS NOTEBOOK IS THE SOURCE CODE FROM

"Monty Hall Paradox" from the Wolfram Demonstrations Project
 http://demonstrations.wolfram.com/MontyHallParadox/

Contributed by: Matthew R. McDougal

A full-function Wolfram Mathematica system (Version 6 or higher) is required to edit this notebook.
GET WOLFRAM MATHEMATICA »

© Wolfram Demonstrations Project & Contributors   |   Terms of Use   |   Make a new version of this Demonstration »