# posterior probability of bag given ball (evidence)

Question:

Given the distribution of the coloured balls in three different bags:
- Bag A: 1 Red 2 Black 2 Blue
- Bag B: 2 Red 4 Black 4 Blue
- Bag C: 10 Red 2 Black 3 Green

we carry out two independent experiments:
1) pick a bag, then pick a ball from the chosen bag.
2) pick a ball uniformly and random from all of the 30 balls.

We observe that the ball is red (for both experiment).
Now, we want to find the posterior probability of ball was taken from bag C given the ball chosen is Red for each of the experiment (i.e. P(Bag C | Red)).

My attempt:
For Experiment 1:
Using Bayes Rule we have:
P(Bag C | Red) = P(Bag C and Red) / P(Red)

From the distribution, we have P(BagC, Red) = 10/30
Now,P(Red)
= (by law of total probability) sum of conditional probability of
P(Red | Bag X) * P(Bag X)
= P(Red|BagC)*P(BagC) + P(Red|BagB)*P(BagB) + P(Red|BagA)*P(BagA)
= (1/3)(10/15) + (1/3)(2/10) + (1/3)(1/5)
= 16/45

And hence P(BagC|Red) = (10/30) / (16/45) = 15/16 ???


For Experiment 2:
this is the part where i am confuse, because intuitively, i dont not see the difference between both question! But i slept over it and think maybe the difference is in the way we calculate P(red), and thats why the following answer:

So using the same formula above, but with difference calculation of the probability of getting a red ball from the bag:

P(Red) = total number of red / total number of balls = 13/30
Hence, P(BagC|Red)
= P(Red, BagC) / P(Red)
= (10/30) / (13/30)
= 10/13


Intuitively, i thought my answer made sense because if we were to choose a bag first, the probability of the red ball coming from bag C will be larger since the proportion of red balls in bag C is significantly higher.
In comparison, if we pick randomly from the pool of 30 balls, the contribution of C into the pool is higher as well (10/13 red balls from C).

I am not entirely sure if my approach is correct here, and would wish that you can validate my answers.

EDIT:
Rectify the error pointed out in the comments

Your answer to the first question is correct. (ETA: Or was, before you edited $\frac{5}{8}$ to $\frac{15}{16}$. $<$g$>$)

Your answer to the second question is incorrect, because the $P(\text{red}, \text{Bag$C$}) = 10/30$, not $10/45$. (That is, out of the $30$ balls, each equally likely to be selected, exactly $10$ of them are both red and in Bag $C$.) You then obtain the correct answer of $10/13$.

• Hi Brian, good catch. However, if thats the case, then my first answer wouldnt be correct as well, isnt it? P(red, bagC) = 10/30, then for the first experiment, we should have P(bagC | Red) = (10/30) / (16/45) = 15/16 – rockstone Apr 21 '16 at 16:48
• @rockstone: No, it was right before. You should have $P(\text{Bag$C$} \mid \text{red}) = \frac{P(\text{red}, \text{Bag$C$})}{P(\text{red})} = \frac{2/9}{16/45} = \frac{5}{8}$. The difference is that the balls are not equally likely in the first problem; the bags are. – Brian Tung Apr 21 '16 at 17:39
• @brain, not exactly sure how you get 2/9. – rockstone Apr 21 '16 at 19:19
• @brain, after some thought, is $\frac{2}{9} = (\frac{10}{15})(\frac{1}{3}) =$ $P(red | BagC) P(C)$. Okay, then, my next question, if $P(A|B)P(B) = P(A, B)$, then for the second part, if we do use Bayes theorem, $P(BagC|red) = \frac{P(red|BagC) P(BagC)} {P(red)} = \frac{P(red, BagC)}{P(red)}$ why do we use $\frac{10}{30}$ instead of $\frac{10}{45}$? hope you can enlighten me on this issue. – rockstone Apr 21 '16 at 19:31
• @rockstone: Because all $30$ balls are equally likely, of which $10$ are both red and in Bag $C$. – Brian Tung Apr 21 '16 at 19:53

In the pool of all $30$ balls, label the balls by the label of the bag they came from. Then, there are $10$ red 'C' balls. So the second question asks for the probability of a ball being a red 'C' ball, given that it is a red ball. There are totally $13$ red balls, and $10$ of these are 'C', so the probability is $\dfrac{10}{13}$.

You can do this using Bayes' theorem too, but you will get the same answer.

• Yes, the second part should be 10/13! – rockstone Apr 21 '16 at 17:04