%%% An implementation of an example of a Discrete Bayesian Network %%% from the paper by E.Chaniak: "Bayesian Networks without Tears" %%% %%% Developed in the PRISM system by Henning Christiansen, October 2006 %%% http://www.ruc.dk/~henning %%% Outcome of random variables (msw's) are binary, i.e. boolean %%% We have given different names to outcomes for different variabeles %%% which may help to increase clarity. %%% You should consult Charniak's paper for the intuitive meaning %%% of the different variables and a drawing of the network. values(fo,[foTrue, foFalse]). values(bp,[bpTrue, bpFalse]). values(lo(_),[loTrue, loFalse]). % lo({foTrue,foFalse}) values(do(_,_),[doTrue, doFalse]). % do({foTrue,foFalse}, {bpTrue,bpFalse}) values(hb(_),[hbTrue, hbFalse]). % hb({doTrue,doFalse}) set_params:- set_sw(fo, [0.15, 0.85]), set_sw(bp, [0.01, 0.99]), set_sw(lo(foTrue), [0.6, 0.4]), set_sw(lo(foFalse), [0.05, 0.95]), set_sw(do(foTrue,bpTrue), [0.99, 0.01]), set_sw(do(foTrue,bpFalse), [0.9, 0.1]), set_sw(do(foFalse,bpTrue), [0.97, 0.03]), set_sw(do(foFalse,bpFalse), [0.3, 0.7]), set_sw(hb(doTrue), [0.7, 0.3]), set_sw(hb(doFalse), [0.01, 0.99]). target(world,5). % This is important for the learning phase data('famOutData.dat'). world(LO, HB):- world(_, _, LO, _, HB). world(FO, BP, LO, DO, HB):- msw(fo, FO), msw(bp, BP), msw(lo(FO), LO), msw(do(FO,BP), DO), msw(hb(DO), HB). /********************** ?- set_params. | ?- chindsight_agg( world(loTrue, hbFalse), world(foFalse,_,_,_,_)). conditional hindsight probabilities: world(fo=0,*,*,*,*): 0.499448272410416 yes | ?- chindsight( world(lo=1, hb=0), world(fo=0,_,_,_,_)). conditional hindsight probabilities: world(fo=0,bp=0,lo=1,do=0,hb=0): 0.440219169184873 world(fo=0,bp=0,lo=1,do=1,hb=0): 0.057171320673360 world(fo=0,bp=1,lo=1,do=0,hb=0): 0.000190571068911 world(fo=0,bp=1,lo=1,do=1,hb=0): 0.001867211483271 yes ******************/