在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
N = 4 ;
dag = zeros( N, N );
C = 1 ;
S = 2 ;
R = 3 ;
W = 4 ;
dag( C, [R S] ) = 1 ;
dag( R, W ) = 1 ;
dag( S, W ) = 1 ;
node_sizes = 2 * ones( 1 ,N);
% node_sizes = [ 4 2 3 5 ];
% 建立有向无环图
onodes = [];
bNet = mk_bnet( dag, node_sizes );
% 建立条件概率表
bNet.CPD{C} = tabular_CPD( bNet, C, 'CPT' , [ 0.5 0.5 ] );
bNet.CPD{R} = tabular_CPD( bNet, R, 'CPT' ,[ 0.8 0.2 0.2 0.8 ] );
bNet.CPD{S} = tabular_CPD( bNet, S, 'CPT' , [ 0.5 0.9 0.5 0.1 ] );
bNet.CPD{W} = tabular_CPD( bNet, W, 'CPT' , [ 1 0.1 0.1 0.01 0 0.9 0.9 0.99 ] );
% 用于推断
engine = jtree_inf_engine( bNet);
evidence = cell( 1 ,N );
evidence{W} = 2 ;
% 添加证据
[engine, loglik] = enter_evidence( engine, evidence );
marg = marginal_nodes( engine, S );
p = marg.T( 2 );
% 添加下雨的证据
evidence{R} = 2 ;
[ engine, loglik ] = enter_evidence( engine, evidence );
marg = marginal_nodes( engine, S );
p = marg.T( 2 );
bar( marg.T ); % Joint distributions
evidence = cell( 1 ,N);
[engine, ll] = enter_evidence(engine, evidence);
m = marginal_nodes(engine, [S R W]);
m.T |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论