# Conditional probability with boxes and fruits

In the book Pattern Recognition and Machine Learning there is a simple problem that is giving me some trouble.

Suppose there are two boxes (figure below). One of them is red and the other one is blue. As you can see, the red box contains 6 oranges and 2 apples and the blue box contains 1 orange and 3 apples.

The probability of choosing the red box is 4/10 and the probability of choosing the blue box is 6/10:

$$p(B=r) = 4/10$$ $$p(B=b) = 6/10$$

Now it says:

... suppose that we pick a box at random, and it turns out to be the blue box. Then the probability of selecting an apple is just the fraction of apples in the blue box which is 3/4, and so $p(F=a|B=b)=3/4$"

In the same way, it carries out the other conditional probabilities:

$$p(F=a|B=r) = 1/4$$ $$p(F=o|B=r) = 3/4$$ $$p(F=a|B=b) = 3/4$$ $$p(F=o|B=b) = 1/4$$

Well, that's where I have the first issue. $p(F=a|B=b)$ implies $\displaystyle \frac{p(F=a,B=b)}{p(B=b)}$, right? But it seems that the calculations are performed considering $p(B=b)$ as the probability of selecting a ball from the blue box instead of the probability of selecting the blue box, which we already know is $p(B=b)=6/10$. For example, in the first case, $p(F=a|B=b)$ is obtained in the following manner:

$$p(F=a|B=b)=\frac{p(F=a,B=b)}{p(B=b)}=\frac{3/12}{4/12}=3/4$$

that is, the numerator is asking for the fraction of fruits that share both properties (being in a blue box and being an apple) and the denominator is asking for the fraction of fruits that are contained in a blue box. The other conditional probabilities also seem to operate under those assumptions. However, in order to calculate $p(F=a)$ (the probability of choosing an apple - regardless of the boxes), it's taking into account the prior probabilities for the boxes:

$$p(F=a)=p(F=a|B=r)p(B=r) + p(F=a|B=b)p(B=b) = 1/4*4/10 + 3/4*6/10 = 11/20$$

In this case, $p(B=b)$ and $p(B=r)$ are the probabilities of choosing a blue or red box, respectively. So why are we using two different definitions of $p(B)$?

-
About your first issue. The conditional probability that the fruit is an apple, given that we picked a fruit from the blue box, is trivial to calculate. Why invoke formulas? The calculation using the formula is wrong. The number $P(B=b)$ is not the fraction of fruit contained in a blue box, it is the probability of choosing the blue box, which we were told is $6/10$. – André Nicolas Feb 21 '13 at 20:19
$P(F=a, B=b)$ is not $3/12$. This assumes you pick one of the twelve fruit at random; rather than picking a box at random, with the given probabilities, and then picking a fruit from it at random. – David Mitra Feb 21 '13 at 20:19
@AndréNicolas Right! The book says that $p(F=a|B=r)=3/4$ but how would you calculate that formally, given that $P(B=b)$ refers to the probability of choosing the blue box. $P(F=a, B=b)$ seems to refer to two independent events. By the way, I wanted to use formulas just to be sure that I understood what was going on but then I got confused with the use of $P(B)$ – Robert Smith Feb 21 '13 at 20:25
@DavidMitra Yes, I know. But how can you calculate $p(F=a|B=b)$ without relying on intuitions? – Robert Smith Feb 21 '13 at 20:26
There is no intuition involved. If I told you there was a box, which happens to be blue, that has $1$ orange and $3$ apples, and asked for the probability you pick an apple, of course you would say $3/4$. Red box? What red box? By the way, I cannot answer your question, since can't distinguish between the apples and the oranges. Green apples would help, a little. Or are some of those things green? – André Nicolas Feb 21 '13 at 20:34