The Monty Hall Problem: A Mathematical Paradox

(both simulations are run independently)

The Monty Hall Problem is a famous probability puzzle named after the host of the American television game show Let’s Make a Deal. The problem presents contestants with a seemingly simple choice but leads to an unintuitive yet mathematically significant conclusion.

The problem is deceptively simple yet counterintuitive, making it a classic example of how human intuition can sometimes conflict with mathematical reasoning.

What is the Monty Hall Problem?

Imagine you are a contestant on a game show. You are presented with three doors. Behind one door is a car (the prize), and behind the other two are goats (losing choices). You have to pick the door with the car.

How the Game Works?

  • The contestant chooses one of the three doors but does not open it.
  • The host, Monty Hall, who knows what’s behind each door, opens one of the remaining two doors that has a goat.
  • The contestant is then given a choice:
    • Stay with their original door.
    • Switch to the other unopened door.

The question is: Should you switch doors, or stick with your initial choice?

At first glance, it may seem that staying or switching does not affect the probability of winning, but a mathematical analysis reveals otherwise.

Origin and Popularity

The problem is named after Monty Hall, who hosted Let’s Make a Deal from 1963 to 1986. Although similar problems existed earlier, it gained widespread attention in 1990, when it was published in Marilyn vos Savant’s column in Parade Magazine. A reader asked about the optimal strategy, and vos Savant correctly stated that switching doors would give a higher probability of winning. This sparked a controversial debate, with thousands of readers, including mathematics professors, initially disagreeing with her solution.

  • Many mathematicians and scholars initially disagreed with her conclusion that switching doors improves the chances of winning.
  • Even Ph.D. holders in mathematics rejected the counterintuitive solution.
  • Eventually, through probability theory and computer simulations, the correctness of the solution was confirmed.
Paradox: Why Switching is Better?

The counterintuitive nature of the Monty Hall Problem lies in the fact that switching doors actually doubles your chances of winning the car.

At first, most people assume that sticking or switching makes no difference and that both options have a 50-50 chance of winning. However, this intuition is wrong.

If you stick with your initial choice, your chances of winning are 1/3. If you switch, your chances are increased to 2/3.

Key Insight:

  • When you first choose a door, the probability of selecting the car is 1/3.
  • The probability of the car being behind one of the other two doors is 2/3.
  • Since Monty always eliminates a losing door, the probability of the remaining unopened door containing the car jumps to 2/3.
  • Switching effectively transfers the 2/3 probability to the unchosen door, making it the better option.
Understanding the Probability Behind the Problem

Let’s break it down mathematically.

  • There are three doors: 1, 2, and 3.
  • The car is randomly placed behind one of the three doors.
  • The contestant chooses one door (say, Door 1).
  • The probability of initially choosing the car is 1/3.
  • The probability of the car being behind one of the other two doors is 2/3.

Now, Monty opens a door with a goat:

  • If the car was behind the contestant’s chosen door (1/3 chance), switching loses.
  • If the car was behind one of the other two doors (2/3 chance), switching wins.
(assuming contestant has selected Door 1, without loss of generality)

Thus, switching wins with a probability of 2/3, while staying wins with a probability of 1/3.

After Monty reveals a goat, he indirectly provides additional information, making switching a better strategy.

Mathematical Explanation Using Conditional Probability

To fully understand the Monty Hall Problem, we can use conditional probabilities to formalize the reasoning. Conditional probability allows us to calculate the probability of an event given that another event has already occurred.

Note: Conditional probability P(A|B) represents the likelihood of event A occurring given that event B has already happened.


Formula for conditional probability:

P(A|B) = P(A ∩ B)/P(B)


- P(A ∩ B) is the probability that both events A and B occur simultaneously.
- P(B) is the probability that event B occurs.

Define the Events

Let’s define the events in the problem:

  • Let  C_1,C_2,C_3  be the events that the car is behind Door 1, Door 2, or Door 3, respectively. Since the car is placed randomly, the initial probabilities are:

    P(C_1) = P(C_2) = P(C_3) = \frac{1}{3}

  • Let  S be the event that you switch your choice after the host reveals a goat.

Analyze the Host’s Action

The host’s action of opening a door is not random; it depends on your initial choice and the location of the car. The host will always open a door that:

  1. Is not the door you initially chose.
  2. Does not contain the car.

This means the host’s action provides additional information that affects the probabilities.

Calculate Conditional Probabilities

Assume you initially choose Door 1 (without loss of generality). There are three possible scenarios:

Case 1: Car is behind Door 1 (C1)

  • Probability:  P(C_1) = \frac{1}{3}
  • The host can open either Door 2 or Door 3, both of which have goats.
  • If you switch, you will lose.

Case 2: Car is behind Door 2 (C2)

  • Probability:  P(C_2) = \frac{1}{3}
  • The host must open Door 3, (since Door 1 is your initial choice and Door 2 has the car).
  • If you switch, you will win.

Case 1: Car is behind Door 3 (C3)

  • Probability:  P(C_3) = \frac{1}{3}
  • The host must open Door 2, (since Door 1 is your initial choice and Door 3 has the car)
  • If you switch, you will win.

Compute the Probability of Winning by Switching

To compute the probability of winning the car by switching, we use the law of total probability and conditional probability on the location of the car.

P(Win by Switching) = P(C_2) \cdot P(Switch Wins | C_2) + P(C_3) \cdot P(Switch Wins | C_3)

From the cases above:

  • If the car is behind Door 2 ( C_2 ​), switching wins with probability 1.
  • If the car is behind Door 3 ( C_3 ​), switching wins with probability 1.

Thus,

P(Win by Switching) = P(C_2) \cdot 1 + P(C_3) \cdot 1 = \frac{1}{3} + \frac{1}{3} = \frac{2}{3}

Compute the Probability of Winning by Staying

If you stay with your initial choice, you win only if the car is behind Door 1 ( C_1 ):

P(Win by Staying) = P(C_1) = \frac{1}{3}

Formal Proof (Optional)

We can also formalize this using conditional probability. Let S be the event that you switch and win.

Then:

P(S) = P(S | C_1) \cdot P(C_1) + P(S | C_2) \cdot P(C_2) + P(S | C_3) \cdot P(C_3)

From the cases above:

- P(S | C_1) = 0 (switching loses if the car is behind Door 1).
- P(S | C_2) = 1 (switching wins if the car is behind Door 2).
- P(S | C_3) = 1 (switching wins if the car is behind Door 3).

Thus,

P(S) = 0 \cdot \frac{1}{3} + 1 \cdot \frac{1}{3} + 1 \cdot \frac{1}{3} = \frac{2}{3}

This confirms that switching doors is the better strategy. The key insight is that the host’s action of revealing a goat provides additional information, which updates the probabilities in favor of switching.

Code Implementation

Here are simulations in both C++ and Python to demonstrate the probabilities:

C++ Implementation

//
//  main.cpp
//  Monty Hall Problem
//
//

#include <iostream>
#include <random>
#include <ctime>

class MontyHallGame {
private:
    std::mt19937 gen;
    std::uniform_int_distribution<> dis;

public:
    MontyHallGame() : gen(time(0)), dis(1, 3) {}

    bool playGame(bool switchDoor) {
        // Place car randomly behind one door
        int carDoor = dis(gen);
        
        // Player's initial choice
        int playerChoice = dis(gen);
        
        // Host opens a door with a goat
        int hostDoor;
        do {
            hostDoor = dis(gen);
        } while (hostDoor == carDoor || hostDoor == playerChoice);
        
        // Switch doors if requested
        if (switchDoor) {
            int newChoice;
            for (int i = 1; i <= 3; i++) {
                if (i != playerChoice && i != hostDoor) {
                    newChoice = i;
                    break;
                }
            }
            playerChoice = newChoice;
        }
        
        return playerChoice == carDoor;
    }
};

int main() {
    MontyHallGame game;
    int trials = 10000;
    int winsWithSwitch = 0, winsWithoutSwitch = 0;
    
    // Simulate with switching
    for (int i = 0; i < trials; i++) {
        if (game.playGame(true)) winsWithSwitch++;
    }
    
    // Simulate without switching
    for (int i = 0; i < trials; i++) {
        if (game.playGame(false)) winsWithoutSwitch++;
    }
    
    std::cout << "Results after " << trials << " trials:\n";
    std::cout << "Switching wins: " << (double)winsWithSwitch/trials * 100 << "%\n";
    std::cout << "Staying wins: " << (double)winsWithoutSwitch/trials * 100 << "%\n";
    
    return 0;
}

Output

Results after 10000 trials:
Switching wins: 66.58%
Staying wins: 33.04%

Python Implementation

import random


class MontyHallGame:
    def play_game(self, switch_door):
        # Place car randomly behind one door
        doors = [1, 2, 3]
        car_door = random.choice(doors)

        # Player's initial choice
        player_choice = random.choice(doors)

        # Host opens a door with a goat
        available_doors = [d for d in doors if d != car_door and d != player_choice]
        host_door = random.choice(available_doors)

        # Switch doors if requested
        if switch_door:
            player_choice = [d for d in doors if d != player_choice and d != host_door][0]

        return player_choice == car_door


def simulate_games(num_trials):
    game = MontyHallGame()
    switch_wins = sum(game.play_game(True) for _ in range(num_trials))
    stay_wins = sum(game.play_game(False) for _ in range(num_trials))

    print(f"Results after {num_trials} trials:")
    print(f"Switching wins: {switch_wins / num_trials * 100:.2f}%")
    print(f"Staying wins: {stay_wins / num_trials * 100:.2f}%")


# Run simulation
simulate_games(10000)

Output

Results after 10000 trials:
Switching wins: 67.17%
Staying wins: 33.19%

Both implementations simulate the game 10,000 times, confirming that switching doors leads to a win about 66.67% of the time, while staying with the original choice wins only around 33.33%. This aligns with our mathematical proof.

The Monty Hall Problem is a great example of how probability can defy intuition. Despite appearing to be equally probable choices, mathematical analysis and simulations prove that switching doors is the optimal strategy and improves the chances of winning.

Leave a Reply

Your email address will not be published. Required fields are marked *