Re: I strongly disagree with Lee's answer

From: Adrian Tymes (wingcat@pacbell.net)
Date: Sat May 12 2001 - 20:46:49 MDT


Spike Jones wrote:

[re: ExtroQuiz]

> Guys we need to set up some test cases and run em
> when you are here for e5. spike

For this we have simulations. This is a pretty simple case...

Case A: Host says nothing, so contestant never has a reason to switch.

Case B: Host reveals a nonprize door after initial choice, always
choosing the contestant's door if the contestant chose a nonprize door;
contestant switches only if contestant's door is revealed.

Case C: Host reveals a nonprize door completely at random; contestant
only switches if contestant's door is revealed.

Case D: Host reveals a nonprize door completely at random; contestant
always switches.

Each trial was for 1000 runs; the number given is the number of times
the contestant won in that trial of that case.
Trial 1 2 3 4 5 Total WinRatio ExpectedWinRatio
CaseA 323 302 360 322 331 1638 0.3276 0.3333
CaseB 674 670 675 661 662 3342 0.6684 0.6666
CaseC 536 534 478 515 515 2578 0.5156 0.5000
CaseD 519 493 489 506 477 2484 0.4968 0.5000

Any other strategies I should run? I've included the code (in Perl)
below, if anyone else would like to double-check my work.

---
use POSIX;
sub pick_other_than {
     # pick a number from 1-3 other than the input
     my ($other) = @_;
     my $choice = ceil(rand(2));
     # $choice is 1 or 2
     # if $other is 3, we're done
     # if $other is 2 and $choice is 2, $choice becomes 3
     # if $other is 1, increment $choice by 2
     $choice += 1 if (($choice == $other) || ($other == 1));
     return $choice;
}
sub do_strategy_a {
     # no info exchanged, so no switch
     return shift(@_);
}
sub do_strategy_b {
     # host reveals a non-prize door
     my ($picked,$prize) = @_;
     if ($picked != $prize) {
          # host always reveals contestant's door if
          # contestant chose non-prize, forcing switch
          my $new_pick = pick_other_than($picked);
          return $new_pick;
     } else {
          # contestant never switches if host reveals
          # a door other than the picked (means contestant's
          # door must have been right)
          return $picked;
     }
}
sub do_strategy_c {
     # host reveals a non-prize door at random
     my ($picked,$prize) = @_;
     my $revealed = pick_other_than($prize);
     if ($picked != $revealed) {
          # contestant never switches if host reveals
          # a door other than the picked
          return $picked;
     } else {
          # switch forced if host reveals picked door
          return pick_other_than($revealed);
     }
}
sub do_strategy_d {
     # host reveals a non-prize door at random
     my ($picked,$prize) = @_;
     my $revealed = pick_other_than($prize);
     if ($picked != $revealed) {
          # contestant always switches if host reveals
          # a door other than the picked
          my $choice = 1;
          $choice += 1 if
               (($choice == $picked) || ($choice == $revealed));
          $choice += 1 if
               (($choice == $picked) || ($choice == $revealed));
          return $choice;
     } else {
          # switch forced if host reveals picked door
          return pick_other_than($revealed);
     }
}
# main code
# switch the do_straegy_* link to
# use different strategies
my $trial = 0,$matches = 0;
while ($trial < 1000) {
     my $picked_door = ceil(rand(3));
     my $prize_door = ceil(rand(3));
     $picked_door =
           do_strategy_d($picked_door,$prize_door);
     $matches++ if ($picked_door == $prize_door);
     $trial++;
}
print $matches . " out of " . $trial . " prizes won\n";


This archive was generated by hypermail 2.1.5 : Sat Nov 02 2002 - 08:07:37 MST