How to do calculate both causal and diagnostic inferences simultaneosly in bayesian networks? Consider a simple Bayesian network as given below.


Question: How to find $P(S|C,W)$?

It is fairly straight forward to compute the causal inference
$ P(W|S) = P(W|S,R)\cdot P(R) + P(W|S,\bar{R})\cdot P(\bar{R})$
where
$ P(R) = P(R|C)\cdot P(C) + P(R|\bar{C})\cdot P(\bar{C})\quad\&\quad P(\bar{R}) = 1-P(R)$
For diagnostic inferences, we make use of the Bayes' theorem as follows
$\displaystyle P(S|W) = \frac{P(W|S)\cdot P(S)}{P(W)}$
where
$P(W) = P(W|S,R)~P(S)~P(R) + P(W|S,\bar{R})~P(S)~P(\bar{R})$
$\quad\qquad +~P(W|\bar{S},R)~P(\bar{S})~P(R) + P(W|\bar{S},\bar{R})~P(\bar{S})~P(\bar{R})$
where $P(S)$ is calculated in a similar way to $P(R)$
How to expand the relation for $P(S|C,W)$?
This involves both causal and diagnostic inferences. So how could this be done?
 A: Here is another way to look at it:
$$P(S|C,W) \cdot P(C,W) = P(S,C,W)$$
$$P(S|C,W) = \frac{P(S,C,W)}{P(C,W)}$$
$$P(S|C,W) = \frac{P(S,C,W)}{P(S,C,W)+P(\bar{S},C,W)}$$
$$P(S|C,W) = \frac{P(C)\cdot P(S|C)\cdot P(W|S,C)}{P(C)\cdot P(S|C)\cdot P(W|S, C)+P(C)\cdot P(\bar S|C)\cdot P(W|\bar S, C)}$$
$$P(S|C,W) = \frac{0.5\cdot 0.1 \cdot P(W|S,C)}{0.5 \cdot 0.1 \cdot P(W|S, C)+0.5\cdot 0.9 \cdot P(W|\bar S, C)}$$
$$P(W|S,C) = P(W,R|S,C) + P(W,\bar R |S,C)$$
$$P(W|S,C) = P(W|R,S,C) \cdot P(R|S,C) + P(W|\bar R,S,C) \cdot P(\bar R |S,C)$$
$$P(W|S,C) = 0.99 \cdot 0.8 + 0.9 \cdot 0.2=0.9720$$
$$P(W|\bar S,C) = P(W,R|\bar S,C) + P(W,\bar R | \bar S,C)$$
$$P(W|\bar S,C) = P(W|R,\bar S,C) \cdot P(R|\bar S,C) + P(W|\bar R, \bar S,C) \cdot P(\bar R | \bar S,C)$$
$$P(W|\bar S,C) = 0.9 \cdot 0.8 + 0 \cdot 0.2=0.720$$
$$P(S|C,W) = \frac{0.5\cdot 0.1 \cdot P(W|S,C)}{0.5 \cdot 0.1 \cdot P(W|S, C)+0.5\cdot 0.9 \cdot P(W|\bar S, C)}$$
$$P(S|C,W) = \frac{0.5\cdot 0.1 \cdot 0.972}{0.5 \cdot 0.1 \cdot 0.972+0.5\cdot 0.9 \cdot 0.720}\approx0.1304$$
