## Bayes Net Demo

Select values for each variable, and then step through the code to compute the joint probability of those values.

Select a value (xi) for each variable (Xi)
Cloudy
Sprinkler
Rainy
Wet Grass

### P(C)

 +c 0.5 -c 0.5

### P(S | C)

 +c +s 0.1 -s 0.9 -c +s 0.5 -s 0.5

### P(R | C)

 +c +r 0.8 -r 0.2 -c +r 0.2 -r 0.8

### P(W | S, R)

 +s +r +w 0.99 -w 0.01 -r +w 0.9 -w 0.1 -s +r +w 0.9 -w 0.1 -r +w 0.99 -w 0.01

### Pseudocode

function bayes_net_joint_probability(bayes_net, x1, x2, x3, x4):

temp_prob = 1:

for Xi in [Cloudy, Sprinkler, Rain, Wet Grass]:

temp_prob = temp_prob * P(Xi | Parents(Xi))

P(x1, x2, x3, x4) = temp_prob

Cloudy Sprinkler Rain Wet Grass Calculated
P(C,S,R,W)
True
P(C,S,R,W)
+c +s +r +w 0
+c +s +r -w 0
+c +s -r +w 0
+c +s -r -w 0
+c -s +r +w 0
+c -s +r -w 0
+c -s -r +w 0
+c -s -r -w 0
-c +s +r +w 0
-c +s +r -w 0
-c +s -r +w 0
-c +s -r -w 0
-c -s +r +w 0
-c -s +r -w 0
-c -s -r +w 0
-c -s -r -w 0
Local Variables
Variable Value
temp_prob 1
Xi None