Talk:Monty Hall problem

message: She said: "Very few raised questions about ambiguity, and the letters actually published in the column were not among those few."
 But not questioning the ambiguity does not mean that the readers understood the assumptions the same way as what she meant. Khamphatg (talk) 21:39, 8 August 2023 (UTC)
thread_title:  Savant's opinion on the readers' understanding of the problem 

message: Since I had forgotten - which is why I initially replied here - and RK20030 might've missed it, I'm pointing out that "discussions on the underlying mathematical issues" should go "on the Arguments page." ​ The section RK20030 created was moved there yesterday. ​ ​ ​ JumpDiscont (talk) 07:23, 9 December 2023 (UTC)
thread_title:  reminder about the [[{{TALKPAGENAME}}/Arguments|Arguments page]] 

message: 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)
replies: text: 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)
thread_title:  Addition to the 'Solutions by simulation' section?