N = 20;
dag = false(N,N);
x1=1;x2=2;x3=3;x4=4;x5=5;x6=6;x7=7;x8=8;x9=9;x10=10;x11=11;x12=12;a=13;b=14;c=15;d=16;e=17;f=18;g=19;t=20;
dag([x4,x5],g)=true;
dag([x2,x3],f)=true;
dag([f,g,x6],d)=true;
dag([d,x1],a)=true;
dag([x7,x8,x9],e)=true;
dag([x10,x11,x12],c)=true;
dag([e,c],b)=true;
dag([a,b],t)=true;
discrete_nodes = 1:N;
node_sizes = 2*ones(1,N);
bnet = mk_bnet(dag, node_sizes);
bnet.CPD{x1} = tabular_CPD(bnet, x1, [0.997 0.003]);
bnet.CPD{x2} = tabular_CPD(bnet, x2, [0.98 0.02]);
bnet.CPD{x3} = tabular_CPD(bnet, x3, [0.996 0.004]);
bnet.CPD{x4} = tabular_CPD(bnet, x4, [0.995 0.005]);
bnet.CPD{x5} = tabular_CPD(bnet, x5, [0.99 0.01]);
bnet.CPD{x6} = tabular_CPD(bnet, x6, [0.998 0.002]);
bnet.CPD{x7} = tabular_CPD(bnet, x7, [0.993 0.007]);
bnet.CPD{x8} = tabular_CPD(bnet, x8, [0.98 0.02]);
bnet.CPD{x9} = tabular_CPD(bnet, x9, [0.992 0.008]);
bnet.CPD{x10} = tabular_CPD(bnet, x10, [0.997 0.007]);
bnet.CPD{x11} = tabular_CPD(bnet, x11, [0.994 0.006]);
bnet.CPD{x12} = tabular_CPD(bnet, x12, [0.995 0.005]);
bnet.CPD{f} = tabular_CPD(bnet, f, [ 1 0 0 0 0 1 1 1]);
bnet.CPD{g} = tabular_CPD(bnet, g, [ 1 1 1 0 0 0 0 1]);
bnet.CPD{d} = tabular_CPD(bnet, d, [ 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1]);
bnet.CPD{e} = tabular_CPD(bnet, e, [ 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1]);
bnet.CPD{c} = tabular_CPD(bnet, c, [ 1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1]);
bnet.CPD{a} = tabular_CPD(bnet, a, [ 1 1 1 0 0 0 0 1]);
bnet.CPD{a} = tabular_CPD(bnet, a, [ 1 1 1 0 0 0 0 1]);
bnet.CPD{t} = tabular_CPD(bnet, t, [ 1 0 0 0 0 1 1 1]);
w=bnet.dag;
draw_graph(w);
engine=jtree inf engine(bnet);
evidence=cell(1,N);
evidence{t}=2;
evid.f
ans=
不能运行下去了???请教各位高手,谢谢!本人新手。


雷达卡


京公网安备 11010802022788号







