Cups and Key Probability Conundrum

I was faced with a typically probability problem yesterday. The problem, as stated, goes this way. Given three (3) cups and a car key. The cups are turned over and the car key is placed under one of the cups. If a player successfully selects a cup with the car key placed under it then he or she wins the car! Pretty straightforward problem right? Ok. The player is given the chance to select one cup out of three. After making the selection, a cup without the key is removed from the choices. Leaving only two cups and one of while contains the key. So it can either be the one you originally selected or the one left. The question is to maximize the chance of winning should the player stick to the current choice or change it?

Intuition dictates that whether one changes or not the answer is the same. Since, the player is not faced with a 50% chance of getting it right whether he or she changes or not. I agree with this line of reasoning since the removal of the cup with no key does not contribute to making one of the remaining choices better than the other.

Another school of thought is that the original probability of getting the answer right is 1/3 while the new probability is 1/2. Therefore, 1/2 is better than 1/3. I find this hard to believe since these two are unrelated probabilities. So, I decided to write a little C++ program to simulate the problem. Since I used a uniform distribution random number generator it, I should be able to get the answer I want. This little program will output the probability of choosing the cup with the key.

#include <boost/random.hpp>
#include <ctime>
#include <iostream>

using namespace std;

int main()
{
int match = 0;
int nmatch = 0;
int max = 100000;

boost::mt19937 rng;
rng.seed(static_cast<unsigned> (time(0)));
boost::uniform_int<> three(1,3);
boost::uniform_int<> two(0,1);
boost::variate_generator<boost::mt19937&,
boost::uniform_int<> > open_cup(rng, three);
boost::variate_generator<boost ::mt19937&,
boost::uniform_int<> > remove(rng, two);

for (int i = 1; i < max; i++)
{
// randomly place keys
int key=open_cup();

// randomly select cup
int select=open_cup();

// randomly remove one of the non-matches
int none=((key+remove())%3)+1;

if (select == key) {
match++;
} else if ( 6-select-none == key) {
nmatch++;
}
}

cout << "% Not changing: " << (match*100/max) << "%" << endl;
cout << "% Changing: " << ((nmatch)*100/max) << "%" << endl;
return 0;
}

The results are pretty clear. The probability of getting the choice right is the same. Therefore, this program demonstrates that it does not matter whether one should change his or her choice or not. If there is something wrong with the program please feel free to comment or email me. Or if they is a better way of modeling this problem.

2 Responses to “Cups and Key Probability Conundrum”

  1. hip2b2 Says:

    I found a really good explanation of the Monty Hall problem or paradox from Wikipedia. Read on!

  2. wyuwp Says:

    i still can’t find what i did wrong in my program since i counted both instead of deducing one from another.

Leave a Reply