'This is the "Three Door Problem" or the "Monty Hall Problem"
'The game show contestant is faced with three doors, behind one
'of which is a prize. He chooses one door, but before that door
'is opened, the host opens another of the three doors revealing
'it to contain nothing. (The host knows which door conceals the
'prize and always opens a door that doesn't have the prize behind
'it.) The contestant then is given the opportunity to switch his
'choice to the remaining unopened door. Should he switch or stay?
'This simulation takes advantage of the fact that if
'the contestant's guess is wrong, then switching is the winning
'move, and that if the guess is right, then switching loses.
'Jim's comments: The value in line 25 controls the number of
'samples. The value in line 26 controls the sample size.
'Because the number of possible winning
'percentages depends on the sample size, the number of bars
'changes, which requires different bin sizes to create good
'good looking histograms. I've used the following:
'n=10 binsize 0.02; n=25 0.0125; n=50 0.005; n=100 0.0025; n=400 0.001.
NAME doorOne doorTwo doorThree
COPY (doorOne doorTwo doorThree) doors
NAME Win Lose
COPY (Win Lose) CoinToss
REPEAT 100000
COPY 100 rptCount
REPEAT rptCount
SAMPLE 1 doors prizeDoor
SAMPLE 1 doors guessDoor
SAMPLE 1 CoinToss CoinResult
IF guessDoor = prizeDoor
SCORE 1 stayingWinsScore
ELSE
SCORE 1 switchingWinsScore
END
IF CoinResult = Win
SCORE 1 WinFlip
ELSE
SCORE 1 LoseFlip
END
END
SUM switchingWinsScore switchingWinsCount
SUM WinFlip WinFlipCount
DIVIDE switchingWinsCount rptCount switchingWinProbability
DIVIDE WinFlipCount rptCount WinFlipProbability
SCORE switchingWinProbability switchingDIST
SCORE WinFlipProbability flipDIST
LET stayingWinsScore = 0
LET switchingWinsScore = 0
LET WinFlip = 0
END
HISTOGRAM percent binsize 0.0025 flipDIST switchingDIST
PERCENTILE switchingDIST (2.5 97.5) SwitchConfidenceInterval
PERCENTILE flipDIST (2.5 97.5) FlipConfidenceInterval
PRINT SwitchConfidenceInterval
PRINT FlipConfidenceInterval