The Monty Hall problem is a brain-teasing scenario in which you’re asked to choose between three doors, with a hidden prize behind one of them, and switching your choice after one door is revealed can dramatically increase your chances of winning, which might sound counterintuitive at first.
What Is The Monty Hall Dilemma?
The game show host leads you to a wall with three closed doors. Behind one of the doors is the car of your dreams, and behind each of the other two is a goat. The three doors all have even chances of hiding the car.
The host, a trustworthy person who knows precisely what is behind each of the three doors, explains how the game will work. First, you will choose a door without opening it. The host will then open one of the two remaining doors to reveal a goat. When this has been done, you will be given the opportunity to switch doors. You will win whatever is behind the door you choose at this stage of the game.
Do you stick to your initial choice or do you switch doors?
Do you raise your chance of winning the car by switching doors?
Not Switching Doors
Define:
1: Door 1
2: Door 2
3: Door 3
C: Car
G: Goat
The first simulation will be sticking with the initial choice.
Code
################################### Simulation 1: Not switching #################################### paramssimulations =10000outcomes <-c("C", "G", "G")resmat_ns <-matrix(ncol =7, nrow = simulations)colnames(resmat_ns) <-c(1, 2, 3, "Initial Choice", "Revealed Door", "Subsequent choice", "Win")options <-c(1:3)# Simulationfor (i in1:simulations){# host sets up the doors: 1 Car and 2 Goats resmat_ns[i,1:3] <-sample(x = outcomes, size =3, replace =FALSE) # guest makes a random choice resmat_ns[i,4] <-sample(x = options, size =1, replace =FALSE)# host reveals a goat and gives choice between chosen closed# and unchosen closed door doors <- resmat_ns[i,1:3] choice <-as.numeric(resmat_ns[i,4])if (resmat_ns[i,choice] =="C"){ # situation where guest chose car resmat_ns[i,5] <-sample(x = options[! options %in%c(choice)], size =1, replace =TRUE) } else { # situation where guest chose goat resmat_ns[i,5] <- options[! options %in%c(choice,which(resmat_ns[i,1:3] =="C")[[1]])] }# Offer to switch DECLINED resmat_ns[i,6] = resmat_ns[i,4]#Win or no winif ( resmat_ns[i,6] ==which(resmat_ns[i,1:3] =="C")[[1]] ){ resmat_ns[i,7] =1# correct choice: win } else { resmat_ns[i,7] =0# wrong choice: lose }}head(as.data.frame(resmat_ns), 10)
1 2 3 Initial Choice Revealed Door Subsequent choice Win
1 G G C 2 1 2 0
2 G C G 1 3 1 0
3 C G G 2 3 2 0
4 C G G 1 3 1 1
5 C G G 2 3 2 0
6 G C G 3 1 3 0
7 C G G 3 2 3 0
8 G C G 1 3 1 0
9 G C G 2 3 2 1
10 G G C 2 1 2 0
Switching
In the second simulation, the strategy is always switching the choice to the remaining door, that is never sticking to the initial choice.
Code
############################### Simulation 2: Switching ################################ paramsresmat_s <-matrix(ncol =7, nrow = simulations)colnames(resmat_s) <-c(1, 2, 3, "Initial Choice", "Revealed Door", "Subsequent choice", "Win")# Simulationfor (i in1:simulations){# host sets up the doors: 1 Car and 2 Goats resmat_s[i,1:3] <-sample(x = outcomes, size =3, replace =FALSE) # guest makes a random choice resmat_s[i,4] <-sample(x = options, size =1, replace =FALSE)# host reveals a goat and gives choice between chosen closed# and unchosen closed door doors <- resmat_s[i,1:3] choice <-as.numeric(resmat_s[i,4])if (resmat_s[i,choice] =="C"){ # situation where guest chose car resmat_s[i,5] <-sample(x = options[! options %in%c(choice)], size =1, replace =TRUE) } else { # situation where guest chose goat resmat_s[i,5] <- options[! options %in%c(choice,which(resmat_s[i,1:3] =="C")[[1]])] }# Offer to switch ACCEPTED resmat_s[i,6] <- options[! options %in%c(choice, resmat_s[i,5])]#Win or no winif ( resmat_s[i,6] ==which(resmat_s[i,1:3] =="C")[[1]] ){ resmat_s[i,7] =1# correct choice: win } else { resmat_s[i,7] =0# wrong choice: lose }}head(as.data.frame(resmat_s), n =10)
1 2 3 Initial Choice Revealed Door Subsequent choice Win
1 G C G 1 3 2 1
2 G C G 2 1 3 0
3 G G C 1 2 3 1
4 G G C 3 2 1 0
5 G G C 1 2 3 1
6 C G G 1 2 3 0
7 G G C 2 1 3 1
8 G G C 3 2 1 0
9 C G G 2 3 1 1
10 G G C 1 2 3 1
Plotting The Results
From the simulations and the plots below, it quickly becomes apparent that the superior strategy is switching doors, leading to a win probability of \(\frac{2}{3}\) as opposed to \(\frac{1}{3}\). Leveraging the law of large numbers, the convergence of the probabilities in simulations shows us a convenient and quick solution to an initially challenging problem.
Therefore, the optimal strategy for the Monty Hall game show would be to always deviate from your initial choice.