展开全部
对上述信息建立贝叶斯网络,代码如下
[plain] view plaincopyprint?
N=8;
dag=zeros(N,N);
A=1;S=2;T=3;L=4;B=5;E=6;X=7;D=8;
dag(A,T)=1;
dag(S,[L B])=1;
dag([T L],E)=1;
dag(B,D)=1;
dag(E,[X D])=1;
discrete_nodes=1:N;
node_sizes=2*ones(1,N);
bnet=mk_bnet(dag,node_sizes,'names',{'A','S','T','L','B','E','X','D'},'discrete',discrete_nodes);
bnet.CPD{A}=tabular_CPD(bnet,A,[0.99,0.01]);
bnet.CPD{S}=tabular_CPD(bnet,S,[0.5,0.5]);
bnet.CPD{T}=tabular_CPD(bnet,T,[0.99,0.95,0.01,0.05]);
bnet.CPD{L}=tabu