# Bayes theorem (solving Monty Hall problem)

9 Dec 2017

Monty Hall problem is a famous probability puzzle: You are in a game show, and in front of you are three doors: Behind one of them there is a car and behind the others goats. You pick a door (1 or 2 or 3) and the hosts, who knows what’s behind doors, opens another door, that has a goat behind. Then asks you: “Do you keep to choose the same door?”, it is your advantage to switch your door?

This could be one of the intuitive ways to determinte every case and compute the sum of each result:

**door** : initial door picked

**car** : door where the car is hiden

**switch** : action to switch 0=Stick 1=Change

**result** : result of the game 0=goat 1=car

door | car | switch | result |
---|---|---|---|

1 | 1 | 0 | 1 |

1 | 1 | 1 | 0 |

1 | 2 | 0 | 0 |

1 | 2 | 1 | 1 |

1 | 3 | 0 | 0 |

1 | 3 | 1 | 1 |

2 | 2 | 0 | 1 |

2 | 2 | 1 | 0 |

2 | 3 | 0 | 0 |

2 | 3 | 1 | 1 |

2 | 1 | 0 | 0 |

2 | 1 | 1 | 1 |

3 | 3 | 0 | 1 |

3 | 3 | 1 | 0 |

3 | 1 | 0 | 0 |

3 | 1 | 1 | 1 |

3 | 2 | 0 | 0 |

3 | 2 | 1 | 1 |

There is a formal view to calculate the result with bayes theorem:

There is a more accurate form if you consider that the sum:

In our case let’s assume we choose door #1

**C** = where the car really is hidden

A priori probabilities:

**H** = door that Monty Hall opens

Assume he opens door #2 without loss of generality, problem is symmetric

First case Monty has half probability to choose door 2 or 3, both have a goat behind:

Second case Monty has to choose the door #3, because door #2 has de car:

Third case Monty has to choose the door #2, because door #3 has the car:

Now we want to know whether to stick with door #1 or switch to door #3 (Monty has opened door #2)