# Calculating Probabilities in Bayesian Network

The Bayesian network below contains only binary states. The conditional probability for each state is listed. From the Bayesian network, calculate the following probabilities: a) $$P(b)$$

b) $$P(d)$$

c) $$P(c \mid \neg d)$$

d) $$P(a \mid \neg c, d)$$

For a) I calculated this to be $$P(b) = \sum_a P(b \mid a) \cdot P(a) = P(b \mid a) \cdot p(a) + P(b \mid \neg a) \cdot P(\neg a) = 0.44$$

b) Exact same method as in a: $$P(d) = \sum_b P(d \mid b) \cdot P(b) = P(d \mid b) \cdot P(b) + P(d \mid \neg b) \cdot P(\neg b) = 0.712$$

Now for c) and d) Im not so sure.

c) I first tried calculating $$P(c,\neg d)$$ using the formula $$P(x_1,...x_n) = \prod_{i = 1}^n P(x_i \mid Parents(x_i))$$ This gives $$P(c,\neg d) = P(c \mid b) \cdot P(\neg d \mid b) = 0.1 \times 0.4 = 0.04.$$ Then Applying Bayes rule gives: $$P(c \mid \neg d) = \frac{P(c,\neg d)}{P(\neg d)} = \frac{0.04}{0.288} \approx 0.139$$

d)

Same approach as in c), I first tried to calculate the joint distribution with the same formula: $$P(a,\neg c, d) = P(a) \cdot P(\neg c \mid b) \cdot P(d \mid b) = 0.8 \times 0.9 \times 0.6 = 0.432$$ Finally, applying Baye's rule again this gives $$P(a \mid \neg c, d) = \frac{P(a,\neg c, d))}{P(\neg c, d)} = \frac{0.432}{0.04} = 10.8$$ which is clearly wrong.

Is anyone able to see what Im doing incorrectly?

• I just stopped here: $P(c,\neg d) = P(c \mid b) \cdot P(\neg d \mid b)$ The terms with $\mid \neg b$ are missing Jan 28, 2021 at 13:05
• @Damien What would be the correct expression for $P(c,\neg d)$? $$P(c,\neg d) = P(c \mid b) \cdot P(\neg d \mid b) + P(c \mid \neg b) \cdot P( \neg d \mid \neg b)$$?
– Pame
Jan 28, 2021 at 13:15
• I think yes. The point is that how $d$ is derived from $b$ is independent from the way $c$ is derived from $b$, according to the figure. Jan 28, 2021 at 13:19
• Not quite. $$P(c,\neg d) = P(c \mid b) \cdot P(\neg d \mid b)\cdot P( b) + P(c \mid \neg b) \cdot P( \neg d \mid \neg b)\cdot P( \neg b)$$ Jan 28, 2021 at 14:57

$$a\to b\overset{\nearrow \raise{1ex}\large c}{\underset{\searrow\lower{1ex}\large d}{\quad\phantom\vert}}$$ coresponds to the factorisation $$\mathsf P(a,b,c,d)=\mathsf P(a)\,\mathsf P(b\mid a)\,\mathsf P(c\mid b)\,\mathsf P(d\mid b)$$ .

We may similarly factorise parts of the diagram

$$\mathsf P(b) = \sum_a \mathsf P(b \mid a) \cdot\mathsf P(a)$$

$$\checkmark$$ Indeed. We factorise the diagram $$a\to b$$ and sum over all values for $$a$$.

$$\mathsf P(d) = \sum_b \mathsf P(d \mid b) \cdot \mathsf P(b)$$

$$\checkmark$$ Quite right. We factorise the diagram $$b\to d$$ and sum over all values for $$b$$; since we calculated $$\mathsf P(b)$$ above.

$$\mathsf P(c\mid\lnot d)$$

You are correct to use the conditional probability's definition. However relevant factorisation is $$\mathsf P(b, c,\lnot d)=\mathsf P(b)\,\mathsf P(c\mid b)\,\mathsf P(\lnot d\mid b)$$ (and likewise for $$\lnot b$$).

So...

\begin{align}\mathsf P(c\mid\lnot d) &=\dfrac{\mathsf P(c,\lnot d)}{\mathsf P(\lnot d)} \\[1ex] &= \dfrac{\sum_b \mathsf P(b)\,\mathsf P(c\mid b)\,\mathsf P(\lnot d\mid b)}{\sum_b \mathsf P(b)\,\mathsf P(\lnot d\mid b)}\\[1.5ex]&=\dfrac{\mathsf P(b)\,\mathsf P(c\mid b)\,\mathsf P(\lnot d\mid b)+\mathsf P(\lnot b)\,\mathsf P(c\mid\lnot b)\,\mathsf P(\lnot d\mid\lnot b)}{\mathsf P(b)\,\mathsf P(\lnot d\mid b)+\mathsf P(\lnot b)\,\mathsf P(\lnot d\mid\lnot b)}\end{align}

Although, since you already have $$\mathsf P(d)$$, you can simply do:$$\mathsf P(c\mid\lnot d) =\dfrac{\mathsf P(b)\,\mathsf P(c\mid b)\,\mathsf P(\lnot d\mid b)+\mathsf P(\lnot b)\,\mathsf P(c\mid\lnot b)\,\mathsf P(\lnot d\mid\lnot b)}{1-\mathsf P(d)}$$

$$\mathsf P(a\mid c,\lnot d)$$

Of course, it is much the same\begin{align}\mathsf P(a\mid c,\lnot d)&=\dfrac{\sum_b\mathsf P(a, b,c,\lnot d)}{\mathsf P(c,\lnot d)}\\[1ex]&=\dfrac{\mathsf P(a)\sum_b\mathsf P(b\mid a)\mathsf P(c\mid b)\mathsf P(\lnot d\mid b)}{\mathsf P(c\mid\lnot d)\,(1-\mathsf P(d))}\end{align}