4 ms·
Here, I wrote some code to prove it: https://gitlab.com/mikenew/monty_hall/-/blob/main/monty_hall.nim https://gitlab.com/mikenew/monty_hall/-/blob/main/monty_ha
by mikenew 5y ago
Here, I wrote some code to prove it: https://gitlab.com/mikenew/monty_hall/-/blob/main/monty_hall.nim https://gitlab.com/mikenew/monty_hall/-/blob/main/monty_hall...
If you have nim installed you can run it yourself with `nim c -r monty_hall.nim`.
I ran 1 million iterations, and here are the results:
Running the simulation 1000000 times where the host chooses doors randomly
500193 # of times the contestant's originally chosen door contained the prize
499807 # of times the remaining door contained the prize
Running the simulation 1000000 times where the host intentionally chooses empty doors
334432 # of times the contestan'ts originally chosen door contained the prize
665568 # of times the remaining door contained the prize
- amluto 5y agoI can’t read your code because I’m not logged in. But you pretty clearly have a bug. If the host does not know which door has a prize and opens a door at random, there is a 1/3 chance the host opens the door with the prize, and the game stops (or otherwise deserves its own logged outcome). And there’s no conceivable way that the host’s knowledge, strategy, or anything else could make the probability that the contestant’s originally chosen door contains a prize be anything other than 1/3. The contestant originally guesses with clean slate and has a 1/3 chance of guessing right, full stop.
- mikenew 5y agoEdit: Sorry, didn't realize that gitlab.com requires you to be logged in to view things (that's dumb). Here it is on github: https://github.com/michaelnew/monty_hall/blob/main/monty_hall.nim https://github.com/michaelnew/monty_hall/blob/main/monty_hal... That is my premise exactly. If the host chooses at random, then there is indeed a 1/3 chance of choosing the door that contains the prize. In which case the game is discarded (or restarted, if you like). If that is the behavior of the host, then in the event that the host randomly chooses a door without the prize (which should happen 2/3 of the time), then the choice between the original door and the remaining door is 50/50. If the host never chooses the door that contains the prize (and therefore the game never has to be restarted), then the host is not choosing randomly. It's stated pretty clearly in the wikipedia article. The 2/3 probability is only true when these three conditions are met: 1. The host must always open a door that was not picked by the contestant. 2. The host must always open a door to reveal a goat and never the car. 3. The host must always offer the chance to switch between the originally chosen door and the remaining closed door.
- amluto 5y agoAh, you’ve invented (and implemented!) a very strange variant indeed. The contestant chooses a door. If they choose right, they win. Otherwise the host effectively flips a coin and, with 50% probability, the game starts over. Otherwise the contestant loses. I’m not convinced this has anything to do with the host’s _knowledge_ per se. For example, consider a different version. The contestant chooses a door. The host then peeks behind a door the door contestant didn’t choose (without showing anyone else what’s there) at random. If the prize isn’t there, the host reveals that there is no prize behind the door. Otherwise the host forgets they peeked and repeats the peek-and-choose step until they randomly get an empty door. Once an empty door has been revealed, the contestant may choose to switch. In this version, the host has no secret knowledge, but the 1/3 vs 2/3 probabilities still happen.
- mikenew 5y ago> The contestant chooses a door. If they choose right, they win. Otherwise the host effectively flips a coin and, with 50% probability, the game starts over. Otherwise the contestant loses. That isn't what happening in the first simulation. The game doesn't end if the contestant chooses the prize door initially. The contestant simply chooses a door. The host randomly chooses between the remaining doors. If they reveal the prize, the game is restarted. If they reveal an empty door, then the game is logged as either "the original door was correct" or "the remaining door was correct". This is the definition of "the host chooses randomly". > The host then peeks behind a door the door contestant didn’t choose (without showing anyone else what’s there) at random. If the prize isn’t there, the host reveals that there is no prize behind the door. Otherwise the host forgets they peeked and repeats the peek-and-choose step until they randomly get an empty door. Picking random doors until an empty one is found absolutely the same thing as randomly choosing amongst the available doors that don't contain a prize. You can implement any function you like here. Either the host always opens a door that does not contain the prize, or the host has a 1/3 chance of revealing the prize and the game is restarted. There is simply no other possibility.
- amluto 5y ago