Monty Hall Game Show Problem

Submitted by Kenrick on Thu, 10/25/2007 - 22:49.
Oct 25 2007 - 10:49pm
Etc/GMT-8

This problem is to simulate the Monty Hall Problem, which was popularized by Marilyn vos Savant in her Parade column. The problem is stated as:

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

Most of my students say it doesn't matter. They expect the probability of getting the car to be 1/2 either way. The fun part is the simulation shows they have a 2/3 chance of getting the car if they switch.

I word my assignment as follows:

Write a program that simulates the game show problem. Your program should randomly select a door (you can use the numbers 1-3) for the prize, pick a door for the contestant, select a door with no prize to reveal, and then determine if you would have won the car by switching or staying. Be sure that your program exactly simulates the process of selecting the door, revealing one, then switching. Do not make assumptions about the actual solution - e.g. don't assume that there is a 1/3 chance of getting the prize.

Once the program is working for one game, modify the program to play 10000 games (with no user input). Count the number of times the car is won by switching vs. sticking with the original choice and compute the probability of winning the car for each scenario. Turn in your code, along with your answer of what choice to make.