# Solving generalized Monty hall problem using Bayes Theorem

Week 1 - Monty Hall Lab

Hello !

I am currently going through the week1 courses and trying to analytically solve the generalized Monty Hall problem where Monty opens k doors out of n. I would like to solve the problem using Bayes theorem instead of the more straightforward solution provided in the lab.

I am using the same notations as provided in the lab :

E_i = \text{ the door behind which the car is. In this case, } i = 1, \ldots, n.

O_{j,..,k+j} = \text{ the set of k doors monty opens, with goats behind}.

We are looking for P(E_1 | O_{j,..,k+j}), which using Bayes theorem can be rewritten as:

P(E_1 | O_{j,..,k+j}) = \frac{P(O_{j,..,k+j} | E_1)\cdot P(E_1)}{P(O_{j,..,k+j} | E_1)\cdot P(E_1) + P(O_{j,..,k+j} | E_1^c)\cdot P(E_1^c)}

Next I find the following expressions for each term :

P(E_1) = 1/n, given that there is n doors and 1 car.

P(E_1^c) = \frac{n-1}{n}, follows from above.

P(O_{j,..,k+j} | E_1) is the probability of Monty opening a random set of k doors, given that the car is behind the first door. That means Monty can pick any set of k doors out of the remaining (n-1) doors. Using the combination formula, we have :

P(O_{j,..,k+j} | E_1) = \frac{1}{{n-1 \choose k}}

Likewise, P(O_{j,..,k+j} | E_1^c) is the probability of Monty opening a given set of k doors, given that the car is not behind the first door. Given that Monty knows what is behind each door, he just has to pick k doors out of the n-2 doors behind which he knows there are goats :

P(O_{j,..,k+j} | E_1^c) = \frac{1}{{n-2 \choose k}}

Now when I replace the following in the formula above and try to solve, I do not get the same solution as the one provided in the lab, namely :

P(E_1 | O_{1,..,k}) = \frac{1}{n}

Could anyone point the flaws in my logic please? Thanks!

Hello @gamarin,

It is not ANY one of all possible sets. It is a certain given set.

To compute P( E_1 | \text{open a certain set of doors} ), you are interested in exactly the probability of opening that one certain set of doors given E_1, i.e. P( \text{open a certain set of doors} | E_1).

If you donâ€™t know what I mean by a certain given set, I strongly recommend you to first demonstrate that you can get the correct answer in the following situation: the steps with n=6 doors (the guest chooses the first door and the host opens the second and the third doors = H = {2, 3}). H here is the certain given set. Then you may try a different H to get some more concrete feeling, before moving on to the generalized version.

Cheers,
Raymond