Wednesday 17 December 2014

The Power of Prior Probabilities: The Monty Hall Problem



I cannot find an example that can describe in a more vivid way the importance of prior probability than the famous Monty Hall problem (having the TV game “Let’s make a deal” as its basis)! There are many explanations how the Monty Hall’s “switch the choice” strategy works. I remember a case when I explained how this works to couple of people and I needed to simulate the game and count the winning cases.

The reason why the result of this game may sound counterintuitive is the fact that the prior probabilities are neglected when processing new information. And while it seems that given chance is fair, in fact it is not. The second catchy  issue in this problem is accounting the choice of the host.

In a nutshell, the game is as follows: the player has a choice of three doors, behind one door is the prize and the remaining two doors are empty. The player chooses one door in a 1/3 probability to win. The host, who knows where the prize is, opens one of the two doors and gives a chance to the player either to switch or not to switch. It is widely known that at the second choice the probability is not 1/2 but 2/3 as the prior probability is also having its place in the game. How come?
Let’s start with the Bayes Theorem:
 
which we read as Probability of event A happens given the happening of even B in the context of event C. For the Monty Hall problem solving the reading would be “probability of having the prize at door A, given the host opened door B in the context the player choice is door C”. Or in a more concise manner: probability of having the prize at the door that has not been initially selected by the player.

Using these fundamentals to the Monty Hall problem:





The first part of the right side is equal to 1 since the host knows where the prize is and will not open the door with the prize.
The second part, the probability of having the Prize in door A given the player chooses door C, is 1/3 (this is the a priori probability).
And the final part of the right side (the denominator in the equation) is 1/2 since there are two doors the host can open – given that one door has already been selected by the player.
 
Using similar statements for probabilities, it can easily be found that the probability of winning the prize in the context of keeping the initial selection unchanged is 1/3.
Briefly, Monty Hall problem states the importance of the prior information, prior decisions, prior probabilities into your current decision-making.
I also made a simple R program for the game (it is very detailed and can be done in a much shorter way). The result of winning the game when changing the initially selected door is 67% (it varies, depends on simulations).

Monty_hall<-function() {
  doors<-1:3
  first_choice<-sample(doors,1) ## randomly select one door, probability to win is 1/3
  prize<-sample(doors,1) ## randomly put the prize behind one door
  if (first_choice==prize) {
    door_for_open=sample(doors[-first_choice],1)
  } else {
    door_for_open=doors[c(-first_choice,- prize)]
  } ## host opens one door that is different than the door with prize and already selected door
  door_switch<-doors[c(-first_choice ,-door_for_open)]
  decision<-0:1 ## 0 is keep original choice; 1 is changing choice
  keep_or_switch<-sample(decision,1)
  if(keep_or_switch==0) {
    choice=first_choice
  } else {
    choice=door_switch
  } ## the player has a choice to select among the two doors remaining after the host opened one door
  if ((keep_or_switch==1) | (choice==prize)) {
    result=1 ## 1 is win, given switch; 0 is lose
  } else {
    result=0
  }
}
 
This can be run – say 10,000 times –for instance using the following codes:
game<-replicate(10000, Monty_hall())
game_win<-game[game==1]  ## we want only the “winning” cases
length(game_win)

No comments:

Post a Comment