Ok, here's the premise. You've got three doors, one with a car and the other two with goats. You pick number 1. Monte Hall opens door number 3 and there is a goat behind it. Should you switch to door number 2. It has been suggested that you will improve your odds if you do. I did a Q&D php program that uses random numbers to play the game with Monte. The code is below.
Below is the result of 10000 random runs at this problem.
Runs:
10000
If you follow monte's advice:
Cars:
6596
Goats:
3404
If you don't switch doors:
Cars:
3404
PHP Code for this
$runs=10000;
$win=0;
$winstay=0;
$fail=0;
for ($j=0;$j<$runs;$j++) {
$car=rand(0,2);
$pick1=rand(0,2); // first pick
if ($car==$pick1) {
$winstay++; // this is if he picked the car on first pick
}
$pick2=0; // monte opens door
// Monte door must not be on picked and can't be a car
if (($pick2==$pick1)|| ($pick2==$car)) {
$pick2=1;
}
if (($pick2==$pick1)||($pick2==$car)) {
$pick2=2;
}
$pick3=0; // alternate pick
// find the door that monte didn't open and is not the first pick
if ($pick3==$pick1||$pick3==$pick2) {
$pick3=1;
}
if ($pick3==$pick1||$pick3==$pick2) {
$pick3=2;
}
if ($pick3==$car) {
$win++;
} else {
$fail++;
}
}