Bayesian Network calculation questions

update

The solution follows obtain the right answer now.

-----------------------------------------------------------------------------

The Question is here

$$P(a_0)=P(a_0|r_0) + P(a_0|r_1) = 0.4$$

$$P(d_0)=\sum_{r,c}P(d_0|r,c)\cdot P(r)\cdot P(c)=0.64$$

\begin{align*} P(c_0|s_0,d_0,a_0) &= \frac{P(c_0,s_0,d_0,a_0)}{P(s_0,d_0,a_0)}\\ &=\frac{P(c_0,s_0,d_0,a_0,r_0)+P(c_0,s_0,d_0,a_0,r_1)}{P(s_0,d_0,a_0)}\\ &=\frac{P(c_0) P(s_0|a_0,d_0)[P(r_0)P(d_0|c_0,r_0) P(a_0|r_0)+ P(r_1) P(d_0|c_0,r_1) P(a_0|r_1)]}{P(s_0|a_0,d_0) \cdot \sum_{r,c}P(c)P(r)P(a_0|r)P(d_0|c,r)}\\ &=\frac{0.6\times 0.6 \times (0.5 \times 1 \times 0.2 + 0.5 \times 0.6 \times 0.6)}{0.6 \times 0.208}\\ &=0.807 \end{align*}

Where \begin{align*} \sum_{r,c}P(c)P(r)P(a_0|r)P(d_0|c,r) &=0.5\sum_{r,c}P(c)P(a_0|r)P(d_0|c,r)\\ &=0.5(0.6\times 1\times 0.2 + 0.6\times 0.6\times 0.6 + 0.4\times 0.7\times 0.2 + 0.4\times 0.1\times 0.6)\\ &=0.208 \end{align*}

I learned Bayesian Network point for the first time |-_-|, what's wrong with my answer?

• Hi. Jason. This is a mathjax-enabled site. Please use this to format your equations and write up your solution rather than a distant snap of a sheet. For help, check Instructions on how to use LaTeX on CrossValidated. Jan 5, 2023 at 10:34
• @User1865345 ok！ I'll do that later. Jan 5, 2023 at 10:38
• how did you obtain the expression in the denominator? I would say that $p(s,a,d)=p(a)p(d|a)d(s|d,a)$ but you have a different expression. And how did you get the numbers to plug in for $p(a)$ for example? Jan 5, 2023 at 12:12
• @Thomas $p(s,a,d)=p(a,d)p(s|d,a)$, Here I should mistakenly think that $a$ and $d$ are independent, so I obtain my expression. But now I try to calculate $p(a,d)$ with the expression $p(a_0,d_0) = \sum_{r,c}p(c)p(r)p(a_0|r)p(d_0|c,r)$, I still can't get the right answer. I'm confused. Jan 6, 2023 at 7:18

For the moment I write my brute force calculation as a reference. Maybe there are smarter ways using more properly the properties of Bayesian Networks, but at least I get the correct answer $$(d)$$. In case I find something smarter will update.

We first define:

$$A=p(c_0,s_0,d_0,a_0)$$, $$B=p(c_1,s_0,d_0,a_0)$$

And note that the probability that we want is:

$$R=A/(A+B)$$

Now:

$$A=\sum_{r,f} p(c_0,r,f,d_0,a_0,s_0)=p(c_0)p(s_0|d_0,a_0)\sum_{r,f}p(r)p(d_0|c_0,r)p(a_0|r)p(f|c_0)$$

Note that we have $$p(r)=0.5$$ and $$p(f|c_0)=0.5$$ for every $$r,f$$ so that this simplifies:

$$A=p(c_0)p(s_0|d_0,a_0)*1/2*1/2*2*\sum_r p(d_0|c_0,r)p(a_0|r)$$

Putting numbers inside:

$$A=0.6*0.6*0.5*(0.2+0.6*0.6)$$

$$B$$ is a bit more cumbersome. We arrive at:

$$B=\sum_{r,f} p(c_1,r,f,d_0,a_0,s_0)=p(c_1)p(s_0|d_0,a_0)1/2 \sum_{r,f}p(d_0|c_1,r)p(a_0|r)p(f|c_1)$$

and the four cases $$(r_0,f_0),(r_1,f_1),(r_0,f_1),(r_1,f_0)$$ must be considered seperately. Up to my calculations:

$$B=0.4*0.6*0.5*(0.7*0.2*0.3+0.1*0.6*0.7+0.7*0.2*0.7+0.1*0.6*0.3)$$

UPDATE: If we first sum over $$f$$ due to normaliazation we can simplify further before plugging in the numbers:

$$B=p(c_1)p(s_0|d_0,a_0)1/2 \sum_{r}p(d_0|c_1,r)p(a_0|r)$$

, leading to the simplified expression for B:

$$B=0.4*0.6*0.5*(0.7*0.2+0.1*0.6)$$

which is equivalent to the previous one.

Finally $$R=A/(A+B) \sim 0.807$$, which is answer $$(d)$$.

• get it！many thanks！！ Jan 5, 2023 at 10:09
• But I just wonder why should we take $f$ into consideration, my original thought is whether $f$ is considered or not, the result will be the same, because $f$ is independent of $a$,$d$ and $s$. Jan 5, 2023 at 10:44
• I should reopen my book that I do not have here but I do not think right now that $f$ and $d$ are independent (for example). In the languange of $d-$separation the path $f->c->d$ is open I think so that $d$ and $f$ are not in general independent. They have a correlation due to a common cause (camera) Jan 5, 2023 at 10:54
• I just noticed that in the calculation of B the sum over f goes away since we have sum_f p(f|c1) and this is 1 by normalizion. I will update the calculation with this trick. This suggests that the calculation may be done in a smarter way using some independence property but at the moment I do not see how... Jan 5, 2023 at 12:25
• Indeed the same trick can be applied to A if we first some over f. Maybe you are right about the role of f I will think of a way to justify it without writing down the explicit summation... Jan 5, 2023 at 12:33

I add an alternative approach, based on the comments of the OP, to evaluate $$p(s_0,a_0,d_0)$$, which is in the previous answer the denominator $$A+B$$.

As suggested by the comments of the OP: $$p(s_0,a_0,d_0)=p(s_0|a_0,d_0)p(a_0,d_0)$$ and since the Bayesian network provides $$p(s_0|a_0,d_0)=0.6$$ we just need the second factor, which is equal to:

$$p(a_0,d_0)=\sum_{r,c} p(r)p(c)p(a_0|r)p(d_0|r,c)$$

( variables $$s$$ and $$f$$ do not enter year because they have only outgoing edges from the set of variables $$a,d,r,c$$ )

Now this is equal to, since $$p(r)=0.5$$, and considering the four cases $$(r,c)$$:

$$p(a_0,d_0)=0.5*(0.6*0.2*1.0+0.4*0.2*0.7+0.6*0.6*0.6+0.4*0.6*0.1)$$

And therefore:

$$p(a_0,d_0,s_0)=0.6*0.5*(0.6*0.2*1.0+0.4*0.2*0.7+0.6*0.6*0.6+0.4*0.6*0.1)$$

One can numerically verify that this expression is equal to the denominator $$A+B$$ in the first answer. Of course one still needs to evaluate the numerator $$A$$ to get to the final result.

• That's right! This way I got the right answer! Much thanks to you again! Jan 12, 2023 at 2:54