**The Beginner Programmer**, and kindly contributed to R-bloggers)

The Monty Hall problem is a famous game which was played in the television show “Let’s make a deal”.

The game goes like this:

There are three doors, behind each door there is either a goat or an amazing sportcar. The contestant wins if they guess where the car is. There are in total 2 goats and the car. Therefore the initial chance of choosing the car is 1/3.

The host asks the contestant to pick a door. Once a door has been chose, the host, who knows where the goats and the car are, opens a door behind which there is a goat and asks the contestant if they want to switch door.

Now the question is: should the contestant change door or should they stay? Is there any statistical reason which could justify either choice?

It might not be that immediate to understand, however the optimal strategy is to change door. In this case, the probability of winning the car increases from 1/3 to 2/3. You can check this by analysing the favourable scenarios over the possible scenarios. However, should we stick with this or should we make a simulation to test this statement out? Let’s go for the simulation with R.

Here are the results:

The simulation confirms that, on the long run, the odds are more favourable if the contestant decides to switch door. Hope this was useful and interesting.

More on the Monty Hall problem: http://en.wikipedia.org/wiki/Monty_Hall_problem

**leave a comment**for the author, please follow the link and comment on their blog:

**The Beginner Programmer**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...