« Essential Software 2009A bug that’s never fixed… »

Modeling the Game Show Problem

A few weeks ago, I ran across this article revisiting “The Game Show Problem.” The Game Show Problem is the form of statistical reasoning that people are generally really bad at, even really smart people. However, Marilyn Vos Savant gave an accurate and correct answer and even provided the correct statistical chance of winning.

This morning, I was looking for a small exercise to get going and decided to model The Game Show Problem. The Python script that I wrote can be found in the extended section. I was surprised when I started it. I found a few programs that pretty much replicate the game show but I didn’t see any that modeled it. Of course, I didn’t look very hard. Besides, this was just to stimulate me a bit before I dove into something more substantial.Here’s the code in Python. I just tossed it together so any comments are appreciated. I wasn’t going for a bulletproof modeling, just something that worked. True to Vos Savant’s word, if you stay, you’re likely to win only about a third of the time but about two-thirds if you switch.

Note that all of the rules stipulated by Vos Savant are in place. The door that is shown cannot be the prize-winning door nor the door that the player chose. Likewise, the new choice cannot be the same door that was originally picked nor the opened door.

from random import randint

count = 100000

def stay():
    correct = 0
    for i in range(count):
        door = randint(0, 2)
        choice = randint(0, 2)
        if choice == door:
            correct += 1
    return (float(correct) / count) * 100.

def switch():
    correct = 0
    for i in range(count):
        door = randint(0, 2)
        choice = randint(0, 2)

        doorToShow = randint(0, 2)
        while doorToShow in (door, choice):
            doorToShow = randint(0, 2)

        newChoice = randint(0, 2)
        while newChoice in (doorToShow, choice):
            newChoice = randint(0, 2)

        if newChoice == door:
            correct += 1
    return (float(correct) / count) * 100.

print stay()
print switch()

One comment on “Modeling the Game Show Problem”

Matt:

December 15th, 2009 at 2:40 am

I was bored the other night while watching ‘21’ and did the same thing in python. I use lists and display the “stage” ([“g”, “g”, “c”] etc) for each iteration, along with the statistical data.

Fun little exercise.

Leave a Reply