in reply to Re^6: Marilyn Vos Savant's Monty Hall problem
in thread Marilyn Vos Savant's Monty Hall problem

Your simulation is bad. $opened is always 1 or 2, depending on whether you picked a car. In fact $opened is (1/3 odds) the same as the door you pick. After that it is coincidence that you did a calculation that came out to the right answer.

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.

#! 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 )
Now that said, let me explain why the odds are what they are for each option.

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

    Although your three scenarios may be pedantically valid, only the first one makes any real sense.

    If there are goats behind two of the doors, then Monty opening the door with the car behind it would make for a really stupid game show. He might as well just open the door you chose since both actions tell you that you picked a goat door.

    I suppose you could argue that the problem as stated doesn't make it absolutely clear that you *know* that there are two goat doors (or that there are *always* two goat doors).

    But as stated, the only reasonable interpretation is the first one (that makes sense for a game show, that fits common sense, not that fits a mathematician's standard for precision).

    As for the real Monty saying that he sometimes opened the "car" door, this is true. And that didn't make the real game show really stupid (yes, I'm sure many regarded the show as plenty stupid, but I'm talking stupid beyond sense, not just a matter of taste) because the real show always (or almost always, I haven't personally reviewed every single episode) had one "goat" door (a joke "prize", and no, it wasn't always a goat), one "car" door (a major prize), and one "appliance" door (a minor prize).

    That makes for a more complex statistics problem (as it should, being a real game show). But it has little more to do with the problem as stated other than being the likely inspiration for it and, later, the inspiration for its retitling as well.

    Also note that Monty had other options besides opening one of the doors. He could have a prize wheeled out and offer you that in exchange for the door. He often pulled cash out of his pocket and offered you that (perhaps in addition to the prize he just wheeled out). It wouldn't have made much sense to call the show "Let's make a deal" without such negotiations. (:

    - tye        

      I didn't model it that way, but who is to say (given the problem statement) that Monty wouldn't choose to open your door first if you didn't choose the car? In that case the analysis comes out to what I showed.

      Indeed in the slight variation of this game known as the shell game, it is indeed traditional to show people right off the bat that they got it wrong. (It is also traditional to remove/re-add the pea by sleight of hand so that the chump playing always loses..but let's ignore that fact.) Indeed that precedent suggests that there might indeed be room for a game show where the host tries to make life hard for the players. Indeed the existence of reality shows suggests that the traditional game show format is not the only possible one with an audience.

      Furthermore even if you do (based on cultural knowledge) find only one possible assumption natural, it is still good to analyze the problem clearly enough to know that that is an assumption. Because while implicit assumptions often are right, every so often you'll run across a problem that you can only get straight by being able to find and correct a wrong assumption that you made. (In my experience, "every so often" comes by pretty frequently...)

Re^8: Marilyn Vos Savant's Monty Hall problem
by Aristotle (Chancellor) on Aug 23, 2004 at 22:54 UTC

    The code for option 3 is quite confusing. It took me a while to figure out exactly what it was doing.

    my @available = grep { $door[ $choice ] eq 'car' ? ( $_ != $choice ) : ( $doors[ $_ ] eq +'car' ) } 0 .. 2;

    Hmm.. I guess that's not much clearer either.

    Update: so I rewrote the code, and I think this is clearer:

    for ( 1 .. 100_000 ) { my @door = 0 .. 2; my $car_door = int rand @door; my $my_pick = int rand @door; @door = grep { $_ != $my_pick } @door; ## Option 1: The host reveals a goat #my @available = grep { $_ != $car_door } @door; # Option 2: The host opens a random unopened door #my @available = @door; ## Option 3: The host tries to be malicious #my @available = @door; #@available = grep { $_ == $car_door } @door if $my_pick != $car_d +oor; my $opened = $available[ rand @available ]; if( $opened == $car_door ) { $my_pick == $car_door ? $skip_car++ : $skip_goat++; next; } ## Count my wins if I stick or switch $my_pick == $car_door ? $stick++ : $switch++; }

    Makeshifts last the longest.

      I don't think that there is a good short way to state it.

      Perhaps the best way is to be verbose as in:

      my @available; if ( $door[ $choice ] eq 'car' ) { # Can't beat him yet @available = grep { $choice != $_ } 0 .. 2; } else { # Make him lose! @available = grep { $doors[ $_ ] eq 'car' } 0 .. 2; }

        How about ?

        my $MontysChoice; if( $doors[ choice ] ne 'car' ) { $MontysChoice = grep{ $doors[ $_ ] eq 'car' } 0 .. 2; } else { $MontysChoice = ( grep{ $_ != $choice } 0 .. 2 )[ rand 2 ]; }

        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re^8: Marilyn Vos Savant's Monty Hall problem
by BrowserUk (Patriarch) on Aug 23, 2004 at 22:41 UTC

    Your simulation is bad. -- Nice catch.

    Since switching makes you right if you were wrong, your odds if you switch are 2/3 - so you want to switch. -- That's the explaination that will stick. Thanks.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon