edit: i ran a monty carlo simulation¹ and i was doing the math wrong. it really does matter if monty knows or not. here's the simulation where he knows:
In [15]: non_censored_trials = got_car_trials = 0
In [16]: for trial in range(100_000):
...: car_door = random.randrange(3) # the other two doors have goats
...: your_door = random.randrange(3)
...: monty_door = random.choice(list({0, 1, 2} - {your_door, car_door}))
...: if monty_door == car_door:
...: print("Monty showed the car, never mind")
...: continue
...: non_censored_trials += 1
...: your_new_choice = next(iter({0, 1, 2} - {your_door, monty_door})) # you change your choice
...: if your_new_choice == car_door:
...: print(f"You got the car because you changed from {your_door} to {your_new_choice}")
...: got_car_trials += 1
...: else:
...: print(f"Too bad you changed; you should have stuck with {your_door}")
(...output omitted...)
In [17]: got_car_trials / non_censored_trials
Out[17]: 0.66921
so in ⅔ of the cases, switching doors gets you the car. by contrast, if monty didn't know which door would reveal a car, it's only ½ of the cases: In [21]: non_censored_trials = got_car_trials = 0
In [22]: for trial in range(100_000):
...: car_door = random.randrange(3) # the other two doors have goats
...: your_door = random.randrange(3)
...: monty_door = random.choice(list({0, 1, 2} - {your_door}))
...: if monty_door == car_door:
...: print("Monty showed the car, never mind")
...: continue
...: non_censored_trials += 1
...: your_new_choice = next(iter({0, 1, 2} - {your_door, monty_door})) # you change your choice
...: if your_new_choice == car_door:
...: print(f"You got the car because you changed from {your_door} to {your_new_choice}")
...: got_car_trials += 1
...: else:
...: print(f"Too bad you changed; you should have stuck with {your_door}")
(...output omitted...)
In [23]: got_car_trials / non_censored_trials
Out[23]: 0.49987257709086
so if monty picked the goat door on purpose, you do gain by switching. but if he just got lucky, you don't______
¹ thank you, manoj
I've always admired folks who can do these sorts of things in their head, while it takes me a bunch of time to inspect the code and convince myself it's an accurate representation of the word problem.
In the random-open case, you really know nothing new about either of the closed doors. If you can talk yourself into switching, you could make an equally good argument for switching back.
In the Monty-knows-and-always-shows-goat case, you have gained information about one of the closed doors. You haven't gained any information about your initial pick door. But the other remaining door, you know there's a 2/3rds chance that Monty was forced to avoid it so as not to reveal the car. Only in the 1/3rd case where you were already on the car does Monty have freedom to open either door willy nilly.
Edit: having written this, thinking about the 100 door case. If 98 random doors open (that aren't the one I picked) then the fact they all contain goats is pretty suggestive that I have the car, or at least 50/50. I'm not convinced by the code example though.
That's exactly the point. If he doesn't know, then it's exactly 50/50 and there is no reason to switch. If he does know, then it's 1/NUM_DOORS versus NUM_DOORS-1/NUM_DOORS, so you'd be crazy not to switch.
The point is, if he picks at random, in the 100 door case, the vast majority of the time he will open the car door while opening those 98 doors. The case where you get to pick again would be exceedingly rare. Conversely, if he only opens goat doors, you will get your second pick 100% of the time.
So you thought that eliminating them you were left with the original 1/3 vs 2/3, when you actually removed half of the 2/3.
-There's a 1/100 chance my door is a car, in which case it doesn't matter which of the others stays closed, it will always be a goat. The game will proceed, and switching will lose.
-There's a 99/100 chance my door is a goat, in which case the car is behind some other door. Choosing 98 out of 99 doors to open at random is the same as choosing 1 out of 99 doors to leave closed at random. So the chance that the car stays hidden in this case (so that switching will win) is 1/99, and 98/99 that the game ends early because the car is revealed.
-Adding it up, the game ends without the chance to make a choice 99/100 * 98/99 = 98/100 of the time. Of the remaining 2%, 1/100 comes from the first case (switching loses) and 99/100 * 1/99 = 1/100 comes from the second case (switching wins). The strategies are equally effective.