Bayesian Network, Sprinkler Example

7.8k Views Asked by At

In reference to the wet grass / sprinkler Bayesian network problem at this site: http://www.cs.ubc.ca/~murphyk/Bayes/bnintro.html

wet grass / sprinkler Bayesian network problem

Pr(S=1 | W=1) has been determined as 0.430.

Could someone please help me expand the expression (numerator and denominator) that yields 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!

3

There are 3 best solutions below

0
On BEST ANSWER

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*}

0
On

The calculation on the website is wrong (probably the author changes the values, but forgot to update the calculations. For instance, based on the values given, $P(W=1)$ computes to $0.5985$. Whereas the website calculation came up with $0.6471$!

By the way, $6471 = 3 \cdot 3 \cdot 719$ (which means there's no way you can get this number by multiplying values given in the table).

0
On

I do not have the privileges to add a comment to @user732478 (https://math.stackexchange.com/users/732478/user732478) so I thought I would add it via a post.

I have been looking into the same problem as the OP.

The probability P(W=1) is 0.64710 as stated on the web-site is definitely the correct value, contrary to the suggestion from the answer referenced above. I thought it would be helpful to anyone else that came across this answer to present the workings for this.

We start with the expression for the factored joint probability as stated in a previous answer. We need to sum over the different probabilities to get the marginal probability $P(W)$ which we will then set to 1 (i.e. True).

$$P(W=1) = \sum _{c,r,s} P(C=c)P(S=s|C=c)P(R=r|C=c)P(W=1|S=s, R=r)$$

There are 3 binary elements, and so 8 possible combinations for $C,R,S$. I don't show the workings for each case rather the result of the product from the equation above, but with the respective values from the tables for the three random variables $C,R,S$. For brevity I will show $P_{CRS}$ as $P_{TTT} \dots P_{FFF}$ as follows:

$P_{TTT} = 0.03960, P_{TTF} = 0.3240, P_{TFT} = 0.009, P_{TFF} = 0.0, P_{FTT} = 0.04950, P_{FTF} = 0.0450, P_{FFT} = 0.180, P_{FFF} = 0.0$

From this we sum to get $P(W=1) = 0.6471$. This is the value quoted on the web site, when using this we arrive at the correct value for $P(S=1|W=1)$ as required in the original question.

For a check, I have also used pgmpy and calculated exactly the same answer.