The solution follows obtain the right answer now.


The Question is here The problemFigure 13 (Bayesian Network)

And my answer 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?

Any advice will be appreciated!

  • $\begingroup$ 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. $\endgroup$ Jan 5, 2023 at 10:34
  • $\begingroup$ Also, please add the self-study tag in your post. $\endgroup$ Jan 5, 2023 at 10:35
  • $\begingroup$ @User1865345 ok! I'll do that later. $\endgroup$
    – Jason Lee
    Jan 5, 2023 at 10:38
  • $\begingroup$ 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? $\endgroup$
    – Thomas
    Jan 5, 2023 at 12:12
  • $\begingroup$ @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. $\endgroup$
    – Jason Lee
    Jan 6, 2023 at 7:18

2 Answers 2


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:



$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:


$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:


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:


which is equivalent to the previous one.

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

  • $\begingroup$ get it!many thanks!! $\endgroup$
    – Jason Lee
    Jan 5, 2023 at 10:09
  • $\begingroup$ 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$. $\endgroup$
    – Jason Lee
    Jan 5, 2023 at 10:44
  • $\begingroup$ 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) $\endgroup$
    – Thomas
    Jan 5, 2023 at 10:54
  • $\begingroup$ 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... $\endgroup$
    – Thomas
    Jan 5, 2023 at 12:25
  • $\begingroup$ 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... $\endgroup$
    – Thomas
    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)$:


And therefore:


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.

  • $\begingroup$ That's right! This way I got the right answer! Much thanks to you again! $\endgroup$
    – Jason Lee
    Jan 12, 2023 at 2:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.