in reply to Re^6: Marilyn Vos Savant's Monty Hall problem
in thread Marilyn Vos Savant's Monty Hall problem
Here is code that lets you try different scenarios and see how Monty's behaviour and knowledge affect the outcome. You can uncomment the scenario that you want to see that behaviour.
Now that said, let me explain why the odds are what they are for each option.#! perl -slw use strict; use List::Util qw[ shuffle ]; my( $stick, $switch, $skip_goat, $skip_car ) = (0, 0, 0, 0); for ( 1 .. 100_000 ) { ## Randomly hide the prizes behind the doors. my @doors = shuffle 'car', 'goat', 'goat'; ## Pick a door my $choice = int rand 3; #### ## Uncomment the option you want here to see different scenarios. ### ## Option 1: The host opens a door that I didn't pick ## and that isn't the car #my @available = grep{ $_ != $choice and $doors[ $_ ] ne 'car' } 0 + .. 2; ## Option 2: The host opens a random door #my @available = grep{ $_ != $choice } 0 .. 2; ## Option 3: The host tries to be malicious #my @available = grep{ $_ != $choice and $doors[ $_ ] eq 'car' } 0 + .. 2; #@available = grep{ $_ != $choice } 0..2 if not @available; #### ## End of options #### # Monty chooses which door to open from the choices # that he might make. my $opened = $available[rand(@available)]; if ($doors[$opened] eq 'car') { $doors[ $choice ] eq 'car' ? $skip_car++ : $skip_goat++; next; } ## Count my wins if I stick or switch $doors[ $choice ] eq 'car' ? $stick++ : $switch++; } printf "Odds of Not getting here if you were originally right: %.3f Not getting here if you were originally wrong: %.3f Win if you don't switch: %.3f Win if you do switch: %.3f\n", $skip_car / (( $stick + $switch + $skip_goat + $skip_car) / 100 ), $skip_goat / (( $stick + $switch + $skip_goat + $skip_car) / 100 ) +, $stick / (( $stick + $switch) / 100 ), $switch / (( $stick + $switch) / 100 )
In Option 1, you pick a door and have 1/3 odds of being right. There are 100% odds that you'll see a goat, so the fact that you saw one tells you nothing. Therefore your odds of being right remain 1/3. Since switching makes you right if you were wrong, your odds if you switch are 2/3 - so you want to switch.
In Option 2, you pick a door and have 1/3 initial odds of being right. However if you were right, then you're guaranteed to see a goat next, while if you're wrong, you have only even odds of seeing a goat next. Therefore the knowledge that you actually saw a goat conveys information - if you do the math just enough information to tell you that you now have even odds of being right.
In Option 3, you again pick a door and have 1/3 initial odds of being right. However the fact that you saw a goat gives you considerable information - it literally tells you that you must be right. Since you're right, you don't want to switch.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Marilyn Vos Savant's Monty Hall problem (common sense)
by tye (Sage) on Aug 24, 2004 at 06:04 UTC | |
by tilly (Archbishop) on Aug 24, 2004 at 15:35 UTC | |
|
Re^8: Marilyn Vos Savant's Monty Hall problem
by Aristotle (Chancellor) on Aug 23, 2004 at 22:54 UTC | |
by tilly (Archbishop) on Aug 23, 2004 at 23:04 UTC | |
by BrowserUk (Patriarch) on Aug 23, 2004 at 23:28 UTC | |
|
Re^8: Marilyn Vos Savant's Monty Hall problem
by BrowserUk (Patriarch) on Aug 23, 2004 at 22:41 UTC |