# Bayes' Net Conditional Probability

I have the following Bayes Net.

And I need to calculate $P(R\mid W)$ and $P(S\mid W)$.

For, $P(S\mid W)$, is it $.1 \cdot .9$ because I multiply the probabilities of those two events that the sprinkler is on given that the grass is wet?

Then, for $P(R\mid W)$, do I calculate is as $.2 \cdot .99$ because I'm calculating the result of the event occurring given the grass is wet? I'm sorry if these are a naive way to approach these, I'm just so confused about Bayes Net and any help to calculate $P(R\mid W)$ and $P(S\mid W)$ would be appreciated!

The general idea is to express the required probability in terms of those that are provided, e.g. $P(S\mid C),\;P(R\mid C),\;P(W\mid S,R)$. Normally, $P(C)$ would also be provided. I'll assume $P(C) = 0.5$.

Firstly, from the definition of conditional probability,

$$P(R\mid W) = P(R,W) / P(W) \qquad\qquad\qquad\qquad\qquad (1)$$

We obtain the two terms on the RHS in turn by: summing over the relevent missing random variables (line 1), applying the Chain Rule (line 2), using the independence properties of the given network (line 3), then expanding the sum and plugging in the numerical values (line 4):

\begin{align} P(W) &= \sum_{c,r,s\in\{T,F\}} P(W,C=c,R=r,S=s) \\ & \\ &= \sum_{c,r,s\in\{T,F\}} P(W\mid C=c,R=r,S=s) P(R=r,S=s\mid C=c) P(C=c) \\ & \\ &= \sum_{c,r,s\in\{T,F\}} P(W\mid R=r,S=s) P(R=r\mid C=c) P(S=s\mid C=c) P(C=c) \\ & \\ &= (0.99\times 0.8\times 0.1 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; r=T,\; s=T)$} \\ &= + (0.9\times 0.8\times 0.9 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; r=T,\; s=F)$} \\ &= + (0.9\times 0.2\times 0.1 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; r=F,\; s=T)$} \\ &= + (0\times 0.2\times 0.9 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; r=F,\; s=F)$} \\ &= + (0.99\times 0.2\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; r=T,\; s=T)$} \\ &= + (0.9\times 0.2\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; r=T,\; s=F)$} \\ &= + (0.9\times 0.8\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; r=F,\; s=T)$} \\ &= + (0\times 0.8\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; r=F,\; s=F)$} \\ & \\ &= 0.6471. \end{align}

Similarly for the other term:

\begin{align} P(R,W) &= \sum_{c,s\in\{T,F\}} P(W,R,C=c,S=s) \\ & \\ &= \sum_{c,s\in\{T,F\}} P(W\mid C=c,R,S=s) P(R,S=s\mid C=c) P(C=c) \\ & \\ &= \sum_{c,s\in\{T,F\}} P(W\mid R,S=s) P(R\mid C=c) P(S=s\mid C=c) P(C=c) \\ & \\ &= (0.99\times 0.8\times 0.1 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; s=T)$} \\ &= + (0.9\times 0.8\times 0.9 \times 0.5) \qquad\qquad\qquad\text{with $(c=T,\; s=F)$} \\ &= + (0.99\times 0.2\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; s=T)$} \\ &= + (0.9\times 0.2\times 0.5 \times 0.5) \qquad\qquad\qquad\text{with $(c=F,\; s=F)$} \\ & \\ &= 0.4581. \end{align}

Substitute these two values back into $(1)$ to give:

$$P(R\mid W) = 0.4581 / 0.6471 = 0.7079.$$

$\\$

The same method can be used to find $P(S\mid W)$.