# Conditional probability with chain rule and marginalisation

I have the following exercise, and I don't understand its solution (the picture):

Consider a student who has the choice to buy or not buy a textbook for a course. We’ll model this as a decision problem with one Boolean decision, B, indicating whether the agent chooses to buy the book, and two Boolean chance nodes, M, indicating whether the student has mastered the material in the book, and P, indicating whether the student passes the course.

A certain student, Sam, has an additive utility function: 0 for not buying the book and -\$100 for buying it; and$2000 for passing the course and 0 for not passing. Sam’s conditional probability estimates are as follows:

P(p|b,m)=0.9

P(m|b)=0.9

P(p|b,¬m)=0.5

P(m|¬b)=0.7

P(p|¬b,m)=0.8

P(p|¬b,¬m)=0.3

Q: What should Sam do?

What I don't understand is why

$$P(p|b) = \sum_{m} P(p|b,m)P(m|b)$$

For example, I tried: $$P(p,b,m) = P(p|m,b)P(m|b)P(b)$$ $$P(p,b,m) = P(m|p,b)P(p|b)P(b)$$ $$P(p|b) = \frac{P(p|m,b)P(m|b)}{P(m|p,b)}$$

But I don't see how

$$\frac{P(p|m,b)P(m|b)}{P(m|p,b)} = \sum_{m} P(p|b,m)P(m|b)$$

Thanks anyone who can help.

It's actually the law of total probability (LTP). If you remove $$b$$ from given part because it is globally given for all expressions in your formula, you'll see it as $$p(p)=\sum_{m'} p(p|m')p(m')$$ which is the format presented in the LTP link. However, if we want to derive it directly, we could write the following first:

$$P(p|b)=P(p,m|b)+P(p,¬m|b)=\sum_{m'}P(p,m'|b)$$

(i.e. given $$b$$, prob. of passing = prob. of passing and mastering + prob. of passing and not mastering). And, the inner term can be expanded as $$P(p,m'|b)=P(p|m',b)P(m'|b)$$ yielding your equation:

$$p(p|b)=\sum_{m'}P(p,m'|b)=\sum_{m'}P(p|m',b)P(m'|b)$$

A final note: in your last equation, LHS $$m$$ and RHS $$m$$ are not the same thing and may lead to confusion easily. That's why I changed it to $$m'$$.

Edit: (for your comment) \begin{align}P(p,m'|b) &=\frac{P(p,m',b)}{P(b)}=\frac{P(p|m',b)P(m',b)}{P(b)}=\frac{P(p|m',b)P(m'|b)P(b)}{P(b)}\\ &=P(p|m',b)P(m',b)\end{align}

• Thanks! Could you please explain how you get this? (What sort of law/rule?) $$\sum_{m'}P(p,m′|b)=\sum_{m'}P(p|m′,b)P(m′|b)$$ – mrg Apr 7 '19 at 11:26
• As in, why is this the case: $$P(p,m′|b)=P(p|m′,b)P(m′|b)$$ – mrg Apr 7 '19 at 11:39
• Remove given $b$ part and you'll see the expression of joint probability: $P(p,m')=P(p|m')P(m')$. You can add any event as given to all these expressions. – gunes Apr 7 '19 at 11:46