Conditional Probability of Bathroom Stall Availability You're walking towards a bathroom which has two stalls, Stall A and Stall B. There can only be two people in the bathroom at one time, and while they're inside, they must be occupying one of the stalls.
Let's say P(A) = probability Stall A is occupied = P(B) = probability Stall Bis occupied = 0.20.
Right before you walk in, somebody walks out (event W). The question is, does this change your belief about the availability of Stall B? Stall Bis your favorite and you'd really like to have it to yourself. What P(B|W)?
I'd like to go over my solution and see if anyone can find a mistake.


*

*I start with Bayes' Theorem P(B|W) = ( P(W|B) * P(B) ) / P(W)

*I use the Law of Total Probability to expand P(W) = P(W|B)*P(B) + P(W|~B)*P(~B)


For the conditional probabilities:


*

*I believe P(W|B) refers to the event where someone has used Stall A and walked out, which should be 0.20

*I think P(W|~B) is a bit trickier. If Stall Bis not occupied, that means that the person walking out could have come from either Stall A or Stall B. For this, I calculate the union of P(A OR B), which is P(A) + P(B) - P(A AND B). Since P(A) and P(B) are independent events, P(A AND B) decomposes into P(A)*P(B). Thus P(W|~B) = 0.36


Tying everything to together, I have P(B|W) = 0.12195, which shows that our belief in Stall Bbeing occupied has decreased.
Does this look right, or have I made an error somewhere?
 A: I'm not sure I understand your reasoning. To me it seems obvious that if nobody walks out of the bathroom, there is a 0.2 probability that stall B is occupied, and given W, we know that one of the stalls must be empty, and the probability is therefore 0.2 that one of the stalls is occupied, and 0.2*0.5 that stall B is occupied. So the probability is now 0.1. I'd be very happy to know if I'm wrong and why!
A: Divide the bathroom three states based on the number of stalls in use. 
The probability that both are in use is Pr(A) * Pr(B) = 0.2 * 0.2 = 0.04
The probability that only one is in use is [Pr(A) - Pr(A and B)] + [Pr(B) - Pr(A and B)] = (0.2 - 0.04) + (0.2 - 0.04) = 0.32. 
The remaining probability is the probability that the stalls are both empty: 1 - 0.32 - 0.04. 
In tabular form as a recap:
+---------------+--------+
| Stalls in Use |   Pr   |
+---------------+--------+
|   Exactly 0   |  0.64  |
|   Exactly 1   |  0.32  |
|   Exactly 2   |  0.04  |
+---------------+--------+

Now, we see someone walk out of the room so we know that the first state (exactly 0 stalls in use) couldn't have been the state of the bathroom as we approached it. We can use Bayes to compute this but we don't know the likelihood of seeing someone leave the bathroom given the different states. 
However, this isn't actually a problem as we know the proportional likelihoods which is enough. We know that the likelihood of there being 0 stalls in use as we walked up is 0 because we saw someone leave. We can assume that if both stalls are in use, we are twice as likely to see someone leave per unit of observation. 
+---------------+--------+------------+
| Stalls in Use |   Pr   | L of W | S |
+---------------+--------+----------- +
|   Exactly 0   |  0.64  |      0     |
|   Exactly 1   |  0.32  |      1     |
|   Exactly 2   |  0.04  |      2     |
+---------------+--------+------------+

The product of the prior probability of the bathroom state and the likelihood gives us something proportional to the posterior probability (this is why it doesn't matter what we pick for the likelihood values so long as "Exactly 2" is twice "Exactly 1"). We can divide by the sum of these products to normalize to the posterior probability. 
+---------------+--------+------------+---------+---------+
| Stalls in Use |   Pr   | L of W | S | Product | Post Pr |
+---------------+--------+----------- +---------+---------+
|   Exactly 0   |  0.64  |      0     |   0.00  |   0.00  |
|   Exactly 1   |  0.32  |      1     |   0.32  |   0.80  |
|   Exactly 2   |  0.04  |      2     |   0.08  |   0.20  | 
+---------------+--------+------------+---------+---------+

So we know that before the person left the bathroom, there was an 80% chance that there was only one stall in use and a 20% chance that both were in use. From here we can compute the probability that B was in use. 
+----------------+---------+------+-----------+
| Initial Stalls | Current |  Pr  | Pr(B | S) |
+----------------+---------+------+-----------+
|    Exactly 0   |    2    |  0.0 |     0.00  |
|    Exactly 1   |    2    |  0.8 |     0.00  |
|    Exactly 2   |    1    |  0.2 |     0.50  |
+----------------+---------+------+-----------+

The sum of the product of the probability of each state by the probability of B being in use for each state gives us the probability that B would be in use given that someone left. So Pr(B | W) = 0.00 * 0.00 + 0.8 * 0.00 + 0.2 * 0.5 = 0.10. 
After seeing someone leave, there is a 10% chance that B is in use relative to the 20% chance prior to seeing someone leave. 
