# Getting started on a Bayesian network word problem, solving conditional probabilities?

I am having a tough time getting started on a homework problem involving computing the conditional probability of some given event. The problem statement is so

Shown below is a Bayes network representing the risk of flooding sewers ($FS$) in a city as dependent on rainfall ($R$), falling leaves ($FL$), thunderstorm ($TS$), and autumn ($A$). Use the conditional probabilities below to determine the conditional probabilities of a thunderstorm for the observable scenarios $FS \wedge A$, $FS \wedge \neg A$, $\neg FS \wedge A$, and $\neg FS \wedge \neg A$.

The conditional probabilities given

\begin{array}{|c|c|c|} \hline \text{FL:} & P(FL|TS\wedge A) & 0.8 \\ \hline \text{} & P(FL|\neg TS\wedge A) & 0.2 \\ \hline \text{} & P(FL|TS\wedge\neg A) & 0.05 \\ \hline \text{} & P(FL|\neg TS\wedge\neg A) & 0.01 \\ \hline \text{R:} & P(R|TS) & 0.7 \\ \hline \text{} & P(R|\neg TS) & 0.1 \\ \hline \text{FS:} & P(FS|FL \wedge R) & 0.5 \\ \hline \text{} & P(FS|\neg FL \wedge R) & 0.2 \\ \hline \text{} & P(FS|FL \wedge\neg R) & 0.05 \\ \hline \text{} & P(FS|\neg FL \wedge\neg R) & 0.01 \\ \hline \text{TS:} & P(TS) & 0.5 \\ \hline \text{A:} & P(A) & 0.33 \\ \hline \end{array}

So my first question is, and I think is probably a dumb question considering the phrase "determine the conditional probabilities", is the question asking for $P(TS|FS, A)$ or just $P(FS, A)$?

So assuming that is correct I think for the first one $P(TS|FS, A)$ I think I should be using the Forward Inference rule outlined in my lecture slides? Though I'm pretty sure I am not applying it correctly.

\begin{align}\ P(TS|FS, A) &= \sum\limits_{R, FL} P(FS|R,FL) P(R, FL) \\[1ex] &+ \sum\limits_{TS} P(R|TS)P(TS) \\[1ex] &+ \sum\limits_{TS, A} P(FL|TS, A)P(TS,A) \end{align}

So my thought when applying the rule is that the first line "takes care" of $FS$ ($A$ is independent above so it is "ok") in the query; by takes care I mean accounts for its dependencies. When this first line was added then $R$ and $FL$ were introduced so the second line then, again, "takes care" of $R$ and the third does so for $FL$. None of the three lines then have any variable which does not have its dependencies in check.

I think I can then apply the chain rule to each of the lines as Forward Inference defines and finally Distribution of Sum. But from there (and well here) I am not sure if that is correct or the way to go.

Can someone steer me in the right direction?

The formulas suggested by stud_iisc have an error: The last equality is incorrect.

If it were correct, then we could have just substituted $P(TS)$ for $P(TS|FS,A)$ -- as that last equality implies for the first factor -- right to begin with and been done.

That type of substitution can only be done by invoking the conditional independence defined by the Markov Property of Bayesian networks: I.e., only if the conditioned variables (those to the right of the "|") include (1) all of the parents of the node to the left of the "|" AND (2) only non-descendants of the node. In the case of $P(TS|FS,A)$, $TS$ has no parents, and $A$ is a non-descendant of $TS$, but $FS$ is a descendant of $TS$.

Here's a derivation of the exact solution:

1. Move everything in the target distribution on the right of the conditional ("|") that is not a root node to the left of the conditional and into the denominator using Bayes Rule: $$P( TS | FS, A ) = \frac{P( TS, FS | A)}{\sum_{ \forall TS}P( TS, FS | A)}$$

2. Move all root nodes on the left of the conditional to the right of the conditional using the Product Rule: $$P( TS, FS | A ) = P( FS | TS, A ) P( TS )$$

• So now we have:

$$P( TS | FS, A ) = \frac{P( FS | TS, A ) P( TS )}{\sum_{ \forall TS}P( FS | TS, A ) P( TS )}$$

3. For every single-conditional that is conditioned upon by variables other than its parents (in this case, $P( FS | TS, A )$), introduce the parents by applying the Sum Rule (i.e., marginalization); $$P( FS | TS, A ) = \sum_{ \forall FL}\sum_{ \forall R}P( FS, R, FL | TS, A )$$

4. Use the Product Rule to factor all non-marginals, non-joints, and non-single-conditionals into single-conditionals and marginals. $$P( FS | TS, A ) = \sum_{ \forall FL}\sum_{ \forall R}P( FS | TS, A, R, FL )P( R | TS, A, FL )P( FL | TS, A )$$

5. Invoke the Markov Property of a BBN to replace all single-conditionals in which the conditioning variables include (1) all of the node's parents and (2) none of the node's descendants. This results in having only factors that are given as node conditional probabilities in the factorization of the joint for the original network: $$P( FS | TS, A ) = \sum_{ \forall FL}\sum_{ \forall R}P( FS | R, FL )P( R | TS )P( FL | TS, A )$$

6. Factor out all terms that do not reference the summed variables. This is what we must compute for all combinations of $FS$ and $A$ asked for in the problem. Each time we do so, we substitute it back into the expression for the target distribution in Step #2 above or into Step #7 below: $$P( FS | TS, A ) = \sum_{ \forall FL}P( FL | TS, A )\sum_{ \forall R}P( FS | R, FL )P( R | TS )$$

7. Finally, for the sake of conciseness, we can express the target distribution in terms of ratios (odds): $$\begin{eqnarray*} P( TS=true | FS, A ) &=& \frac{1}{ 1 + \text{Odds}( TS = false | FS, A )} \\ &=& \frac{1}{ 1 + \frac{ P(TS = false)}{P(TS = true )}\frac{P( FS | TS=false, A )}{P( FS | TS=true, A )} } \\ \end{eqnarray*}$$

Hope that looks like help!

Hint:

Yes, you need to compute $P(TS|FS, A)$ (and several others for your assignment.)

Applying law of total probability and chain rule properly,

\begin{align} P(TS|FS, A) &= \sum_{R,FL} P(TS,R,FL|FS, A) \\ &= \sum_{R,FL} P(TS|FS, A) P(R|TS,FS, A) P(FL|R,TS,FS, A) \\ &= \sum_{R,FL} P(TS) P(R|TS) P(FL|TS, A). \end{align}

• Following through the lecture and your hint I think I understand a bit more.. My questions still are though. When the question states $FS \wedge \neg A$ does it mean, in the more conventional terms $P(TS | FS=true, A=false)$?, if so, should I then end with a pdf for $TS$ at the end of each of the given queries? – KDecker Mar 5 '17 at 15:37