had started a href="http://www.rosettacode.org/wiki/Monty_Hall_simulation">new
topic on Rosetta Code on the Monty Hall problem, using an
example I had laying around that I had written in Python to simulate
the effects of different player strategies. The game goes like this:
- The
contestant in in front of three doors that he cannot see
behind.. - The three doors conceal one
prize and the rest being booby prizes, arranged randomly. - The
Host asks the contestant to choose a door. - The host
then goes behind the doors where only he can see what is concealed,
then always
opens one
door, out of the other s not chosen by the contestant, that
must reveal a booby prize to the contestant. - The
host then asks the contestant if he would like either to stick with his
previous choice, or switch and choose the other remaining closed door.
turns out that if the contestant follows a strategy of always switching
when asked, then he will maximise his chances of winning..
I
then re-wrote the simulator in AWK (gawk), so there are now
at least two implementations of the simulator on Rosetta Code.,
The
simulator results show that:
- A strategy of
never switching wins 1/3rd of the time. - A strategy
of randomly switching wins 1/2 of the time. - A
strategy of always switching wins 2/3rds of the time.
I posted my R-project code to Rosetta Stone as well, as well as at my blog http://writeonly.wordpress.com/2008/09/13/monty-hall-in-r/. Thanks for the challenge!
ReplyDelete