# Bayesian Network, Sprinkler Example

In reference to the wet grass / sprinkler Bayesian network problem at this site: http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html Pr(S=1 | W=1) has been determined as 0.430.

As a try, to begin with ...

Pr(S=1 | W=1) = P(S=1, W=1) / P(W=1) = [P(S=1, W=1 | R=1)P(R=1) + P(S=1, W=1 | R=0)P(R=0) ] / P(W=1)

and then, R depends on C; there is more to denominator for sure.

Help is appreciated!

We will need to compute $P(W=1)$ (the denominator), so we do this first. \begin{align*} &\phantom{{}={}}P(W=1)\\ &=\sum_{c=0}^1 \sum_{r=0}^1 \sum_{s=0}^1 P(W=1,C=c,R=r,S=s)\\ &= \sum_{c=0}^1 \sum_{r=0}^1 \sum_{s=0}^1 P(W=1 \mid S=s,R=r) \cdot P(S=s \mid C=c) \cdot P(R=r \mid C=c) \cdot P(C=c)\\ &= \sum_{c=0}^1 P(C=c) \sum_{r=0}^1 P(R=r \mid C=c) \sum_{s=0}^1 P(S=s \mid C=c) \cdot P(W=1 \mid S=s,R=r). \end{align*}
To answer your question, expand the numerator, and then plug in the result for $P(W=1)$ in the denominator. \begin{align*} &\phantom{{}={}}P(S=1 \mid W=1)\\ &= \frac{P(S=1,W=1)}{P(W=1)}\\ &= \frac{1}{P(W=1)}\sum_{r=0}^1 \sum_{c=0}^1 P(S=1,W=1,R=r,C=c)\\ &= \frac{1}{P(W=1)}\sum_{r=0}^1 \sum_{c=0}^1 P(W=1 \mid S=1,R=r) \cdot P(S=1 \mid C=c) \cdot P(R=r \mid C=c) \cdot P(C=c)\\ &= \frac{1}{P(W=1)} \sum_{c=0}^1 P(C=c) P(S=1 \mid C=c) \sum_{r=0}^1 P(R=r \mid C=c) \cdot P(W=1 \mid S=1,R=r) \end{align*}