Talk:Monty Hall problem

Latest comment: 23 hours ago by TheGoatOfSparta in topic 50/50
Former featured articleMonty Hall problem is a former featured article. Please see the links under Article milestones below for its original nomination page (for older articles, check the nomination archive) and why it was removed.
Main Page trophyThis article appeared on Wikipedia's Main Page as Today's featured article on July 23, 2005.
Article milestones
DateProcessResult
May 3, 2005Peer reviewReviewed
June 25, 2005Featured article candidatePromoted
January 29, 2007Featured article reviewKept
May 18, 2008Featured article reviewKept
June 13, 2011Featured article reviewDemoted
Current status: Former featured article

50/50

edit

Addition to the 'Solutions by simulation' section?

edit

Can I propose an addition to the 'Solutions by simulation' section - a simplified Python script to give the following result (approximately)

Overall success rate given a stick or switch strategy
win_rate(monty_knows=True, will_switch=True, give_overall_result=True) = 0.6641
win_rate(monty_knows=True, will_switch=False, give_overall_result=True) = 0.3349
win_rate(monty_knows=False, will_switch=True, give_overall_result=True) = 0.3359
win_rate(monty_knows=False, will_switch=False, give_overall_result=True) = 0.3254
Success rate at the point where the contestant has a choice to stick/switch
win_rate(monty_knows=True, will_switch=True, give_overall_result=False) = 0.6685
win_rate(monty_knows=True, will_switch=False, give_overall_result=False) = 0.3337
win_rate(monty_knows=False, will_switch=True, give_overall_result=False) = 0.5004
win_rate(monty_knows=False, will_switch=False, give_overall_result=False) = 0.5002

The Python code is as close to pseudo code as I could make it.


""" Monty Hall probability calculator. """

import random  # Random number generator module

def random_door(except_doors):
    """ Return a random door number which in not in the list given. """
    while True:
        n_doors = 3
        door = random.randrange(1, n_doors + 1)   # Return 1, 2 or 3
        if door not in except_doors:
            return door

def win_rate(
        monty_knows: bool,
        will_switch: bool,
        give_overall_result: bool) -> float:
    """
    monty_knows:
      True if Monty knows which door has the prize, False otherwise.
    will_switch:
      True if, given a choice, the contestant will switch doors.
    give_overall_result:
      True if we want the probability of winning with a given strategy
      False to give the probability of winning from the point when a stick or
            switch choice is made.
    Returns: Probability of contestant winning given the test criteria above.
    """
    # Note: Doors are numbered 1, 2, 3...
    runs = 0                # The number of valid games
    wins = 0                # The number of times the contestant has won so far
    while runs < 10000:
        runs = runs + 1     # Increment the run count (may get decremented later)
        prize_door = random_door(except_doors=[])   # Door with the prize
        choose_door = random_door(except_doors=[])  # Door chosen by the contestant
        if monty_knows:
            # Monty knows which door has the prize.
            # He chooses to open the door without a prize
            second_door = random_door(except_doors=[choose_door, prize_door])
            # The contestant must choose to switch or stick
            if will_switch:
                choose_door = random_door(except_doors=[choose_door, second_door])
        else:
            # Monty does not know which door has the prize
            # He chooses one of the other doors to open
            second_door = random_door(except_doors=[choose_door])
            if second_door == prize_door:
                # Monty has opened the second door and revealed the prize, so
                # the contestant loses.
                if not give_overall_result:
                    # We want to give the probability of winning from the point
                    # of being given a choice, so we discard this scenario from
                    # the results.
                    runs = runs - 1
            else:
                # The second door does not have the prize.
                # The contestant must choose to switch or stick
                if will_switch:
                    choose_door = random_door(except_doors=[choose_door, second_door])
        # Has the contestant won?
        if choose_door == prize_door:
            wins = wins + 1
    return wins / runs

if __name__ == '__main__':
    print("Overall success rate given a stick or switch strategy")
    print(f"{win_rate(monty_knows=True, will_switch=True, give_overall_result=True) = }")
    print(f"{win_rate(monty_knows=True, will_switch=False, give_overall_result=True) = }")
    print(f"{win_rate(monty_knows=False, will_switch=True, give_overall_result=True) = }")
    print(f"{win_rate(monty_knows=False, will_switch=False, give_overall_result=True) = }")
    print("Success rate at the point where the contestant has a choice to stick/switch")
    print(f"{win_rate(monty_knows=True, will_switch=True, give_overall_result=False) = }")
    print(f"{win_rate(monty_knows=True, will_switch=False, give_overall_result=False) = }")
    print(f"{win_rate(monty_knows=False, will_switch=True, give_overall_result=False) = }")
    print(f"{win_rate(monty_knows=False, will_switch=False, give_overall_result=False) = }") 

92.239.201.60 (talk) 09:02, 7 June 2024 (UTC)Reply

This article, like most articles, is better off without code samples, which are meaningless to many readers. The procedure for simulating with cards is sufficient to make the point and can be understood and implemented by anyone. MrOllie (talk) 13:07, 7 June 2024 (UTC)Reply

Ignorant Monty / Monty Fall - current explanation is incomplete

edit

The table currently describes "Ignorant Monty" solution as "switching wins 50%". However, in this variant, switching and staying are indifferent (when a goat has been revealed by chance by Ignorant Monty) and both in fact win 50%. Suggest that table be updated to state that "switching or staying both win 50%". This is given already in the citation for that Variant, if you read the second page of https://en.wikipedia.org/wiki/Monty_Hall_problem#CITEREFRosenthal2005a 2600:8801:17E2:0:30D0:6149:CBE5:D00B (talk) 17:15, 19 November 2024 (UTC)Reply

The completely unnecessary long-winded discussion mainly confuses readers

edit

This article is much more confusing than enlightening.

Instead of straighforwardly explaining the problem and its correct solution, it goes into all manner of alternative theories.

Furthermore, the illustrated explanation contains statements "Probability = 1/6", "Probability = 1/3", "Probability = 1/3", "Probability = 1/6",

without ever stating what these numbers are the probabilities of.

That is very unclear writing.

I hope someone familiar with this subject will fix this.