# What is the P(A|C) if we know B depends on A and C depends on B?

Given a Bayesian network that looks like the following:

A->B->C


How do we compute P(A|C)? My initial guess would be:

P(A|C) = P(A|B) * P(B|C) + P(A|not B) * P(not B|C)

-
This probably belongs on math.stackexchange.com –  Raymond Chen Nov 28 '11 at 0:00

## migrated from stackoverflow.comNov 28 '11 at 0:13

This question came from our site for professional and enthusiast programmers.

I would prefer $\Pr(A|C) = \Pr(A|C,B) \Pr(B|C) + \Pr(A|C, \text{not } B) \Pr(\text{not } B|C)$ and the following counterexample shows why there is a difference.

Prob A B C
0.1  T T T
0.1  F T T
0.1  T F T
0.2  F F T
0.2  T T F
0.1  F T F
0.1  T F F
0.1  F F F


Then in your formulation $\Pr(A|C)=\frac{2}{5}$, $\Pr(A|B)=\frac{3}{5}$, $\Pr(B|C)=\frac{2}{5}$, $\Pr(A|\text{not } B)= \frac{2}{5}$, $\Pr(\text{not } B|C)= \frac{3}{5}=6$ but $\frac{2}{5} \not = \frac{3}{5} \times \frac{2}{5} + \frac{2}{5} \times \frac{3}{5}$.

In my formulation $\Pr(A|C,B) = \frac{1}{2}$ and $\Pr(A|C, \text{not } B)=\frac{1}{3}$ and we have the equality $\frac{2}{5} = \frac{1}{2} \times \frac{2}{5} + \frac{1}{3} \times \frac{3}{5}$.

-
Isn't the Bayesian network $A \rightarrow B \rightarrow C$ supposed to be locally Markov in the sense that given $B$, the sole parent of $C$, $C$ is conditionally independent of all nondescendants (such as $A$), that is, $P(A\mid B,C)$ should equal $P(A\mid B)$? While Henry's equation is correct in the general case, the probability assignment in his counterexample is not compatible with the Bayesian network $A \rightarrow B \rightarrow C$. For the probability assignments required by the locally Markov property in this case, @ArKitect's solution is correct. –  Dilip Sarwate Nov 28 '11 at 2:42
To extend this answer in response to Henry's answer and Dilip's comment - yes, the network structure implies that $P(A|B,C) = P(A|B)$, so, taking a problem-specific shortcut, Dilip's original answer is correct.