rtay.io/blog/post

Switch to dark mode

The Monty Hall Problem

Decided to change the pace up a bit today and just take on a simple programming challenge. I decided to simulate the Monty Hall problem.

Basically, there’s 3 doors. Behind 2 of the doors are goats, and behind the other door is a car. The player chooses a door, and the host (who knows what’s behind the doors), opens a different door which has a goat. The player then gets given the choice to switch to the other available door.

Counter-intuitively, switching doors gives you a 2/3 chance of winning the car, whereas sticking to the initial choice only has a 1/3 chance - the same as if a goat wasn’t revealed at all.

Using some simple python I can randomly simulate the problem for thousands of iterations, and get an approximate answer of 2/3 when switching.

Here’s my code if anybody is interested:
https://gist.github.com/darkrilin/7cbbb99d227412c0b7179f5d9d1a4b64


A post by @rtaylz