Monty Hall Problem Demonstration

Here is a terminal demonstration of the monty hall problem in python with nicely colored text.
You can try it out here: https://replit.com/@CSharpIsGud/MontyHallDemo?v=1
It’s configurable so that you can change the number of doors, you won’t see a big difference if you choose the traditional 3 doors, but if you have more doors you will choose the prize door much more often if you switch.

Or if you don’t know what the monty hall problem is, you can read a screenshot of the included explanation from the demo.
image

3 Likes

Could you explain why there would be a 99% chance of winning if you switch and there are 100 doors? Is that assuming that there are things behind nearly all doors?

There would only be one prize and every other door would be empty. But even after all but 2 doors have been revealed out of 100 doors. Switching is a 99% win.

Put the door you chose in group 1.
Now put all the 99 other doors in group 2.

The chance of the prize being in group 2 is much higher than group 1, since there are many more doors in group 2.
The result is that once every door but one in group 2 is revealed to be empty, the entire probability of group 2 converges on that single door.

1 Like

But what if the door they originally picked was the correct one? Then if you switch then you lose… Also, it would still be a 1/3 chance no? Because even if you choose to switch the doors, again, there is still a chance that the one you chose first was correct, so it would, in fact, be a 1/3 chance.

And if you make the number bigger, then it is an even LESSER chance of winning, not 99% XD.

The monty hall problem would not exist if that were the case. That’s why the demo allows you to change the number of doors. If you set the number of doors higher you will notice the effect get very strong.
Indeed if you were plainly choosing from a set of 3 doors, it would be a 1/3 chance.
But since the host opens one of the other doors that doesn’t have the prize it’s a 2/3 chance the other remaining door has the prize instead.

You can experience this by setting the amount of doors higher, you might not notice it when it’s just a 2/3 chance but as you increase the number of doors it will start getting impossible to win if you don’t switch.

First try XD:
image

It’s still a matter of probabilities. Try 100 doors. 99/100 chance of winning on switch is much higher than 4/5

First try AGAIN:

might be broken I’ll have to check

Idk, the code looked fine to me XD.

When I try it with lots of doors I get the expected results.

If you’re getting it first try with a lot of doors and you are choosing not to switch choices you should go to vegas.

Lol or I should go on The Price is Right.

Tell that to the Linux kernel (which is responsible for generating random data afaik)…

I read about this in a book about paradoxes, it is kinda cool and I fooled some people with it (:

3 Likes