SPRINKLER model { cloudy ~ dcat(p.cloudy[]); sprinkler ~ dcat(p.sprinkler[cloudy,]); rain ~ dcat(p.rain[cloudy,]); wetgrass ~ dcat(p.wetgrass[sprinkler,rain,]) } list( #hard evidence , uncomment and instantiate... # sprinkler = 1, # cloudy = 1, # rain = 1, wetgrass = 1, #initial distributions p.cloudy = c(0.5,0.5), # conditionals p.sprinkler = structure(.Data = c(0.50, 0.50, 0.90, 0.10), .Dim = c(2,2) ), p.rain = structure(.Data = c(0.80, 0.20, 0.20, 0.80), .Dim = c(2,2) ), p.wetgrass = structure(.Data = c(1., 0.0, 0.1, 0.9, 0.1, 0.9, 0.01, 0.99), .Dim = c(2,2,2) ) ) #end list # p.sprinkler = S0|C0 S1|C0 # S0|C1 S1|C1 # # p.rain = R0|C0 R1|C0 # R0|C1 R1|C1 # p.wetgrass = S0 R0 W0| S0 R0 W1|S0 R0 # S0 R1 W0| S0 R1 W1|S0 R1 # S1 R0 W0| S1 R0 W1|S1 R0 # S1 R1 W0| S1 R1 W1|S1 R1 #