Bayesian network fundementals

What is the formula of $P(W)$ at this Bayesian network? PS 1: Does this formula give me $P(W)$ or not?

$P(Cloudy) \times P(Sprinkler|Cloudy) \times P(Rain|Cloudy) \times P(Wet Grass | Sprinkler, Rain)$

PS 2: How we can find the formula of $P(R|S)$?

As a whole the network represents the factorization of the multivariate joint distribution into a product of simpler factors:

$p(c,r,s,w)=p(w|r,s)p(s|c)p(r|c)p(c)$

with $c \in C$ representing a particular state for cloudy variable (i.e. the variable cloudy can take on any state $c$ in the set $C$, $s \in S$ for the sprinkler variable and so on. I'm going to assume that these are discrete variables.

The structure of the network tells you about the conditional relationships that are present. In this case, wet-grass is conditionally independent of cloudy, given sprinkler and rain. That is, if you specified particular states for the variables sprinkler and rain the probability distribution over the states for wet-grass would not change if you changed the state (or distribution over) cloudy.

Anyway, you can get the marginal distribution for $w$ via

$p(w) = \sum_{c \in C,s \in S,r \in R} p(w,r,s,c)=\sum_{c \in C,s \in S,r \in R} p(w | r,s)p(r|c)p(s|c)p(c)$

i.e. by summing over the other variables. In general, the added value of the network (factored) representation is that the factorization makes it easier to compute the sum.

In doing this case by hand, I wouldn't factorize $S$ and $R$ and just work with

$p(c,r,s,w)=p(w|r,s)p(r,s|c)p(c)$

For computation, you can

• just think of $p(c)$ as a vector (of length $\vert C \vert$) non-negative numbers $p_c$ (they happen to sum to $1$).
• consider $p(r,s|c)$ as an array with three indices $p_{r\ s\ c}$.
• compute the sum $p(r,s)=p_{r\ s}=\sum_{c=1}^{\vert C \vert} p_{r\ s\ c} p_c$, that is take the slice of the array $p_{s\ r\ c}$ with a particular $c$ index, multiply it by the $p_c$ value and then incorporate it into the sum.
• This results in a two-index array $p_{s\ r}$ ,
• Then do the same kind of multiply and sum to get the final answer $p(w)=p_w = \sum_{s=1}^{\vert S \vert} \sum_{r=1}^{\vert R \vert} p_{w\ r\ s} p_{r\ s}$

Similarily $p(r|s)= \frac{p(s,r)}{p(s)}=\frac{ \sum_{w \in W,c \in C} p(c,s,r,w)}{\sum_{w \in W,c \in C,r \in R} p(c,s,r,w)}$ which again involves appropriate sums over the (factored) joint distribution.

• Thanks for your reply. I am new to statistics so can you be more clear with that sum formula. i.e. what is the formula for ∑ c,s,r p(w|s,r)p(s|c)p(r|c)p(c); does it-> p(w|s,r)p(c)p(r|c)p(s|c)... – kamaci Nov 16 '12 at 15:00