FullBNT学习笔记之一(matlab)

</pre>      <span style="font-size:18px;">首先来看一个草地湿润模型,Cloudy表示天气是否多云C=1(F)表示False,C=2(T)表示True,一下表示均相同,Sprinklet表示洒水车是否出动,Rain表示是否下雨,WetGrass表示草地是否是湿的。旁边的表格表示各种条件概率。</span></div><div style="text-align: center;"><span style="font-size:18px;"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAc0AAAGICAYAAAAj0LvCAAAgAElEQVR4Ae2djZKlNg9tb9/K+79y39KXuxPFY4MBYyR7naougy3rZwnYw+nJ5Of39/f3//CBAAQgAAEIQOCUwP89tcAAAhCAAAQgAIH/EUA0uRAgAAEIQAACnQQQzU5QmEEAAhCAAAQQTa4BCEAAAhCAQCcBRLMTFGYQgAAEIAABRJNrAAIQgAAEINBJANHsBIUZBCAAAQhAANHkGoAABCAAAQh0EkA0O0FhBgEIQAACEEA0uQYgAAEIQAACnQQQzU5QmEEAAhCAAAQQTa4BCEAAAhCAQCcBRLMTFGYQgAAEIAABRJNrAAIQgAAEINBJANHsBIUZBCAAAQhAANHkGoAABCAAAQh0EkA0O0FhBgEIQAACEEA0uQYgAAEIQAACnQQQzU5QmEEAAhCAAAQQTa4BCEAAAhCAQCcBRLMTFGYQgAAEIAABRJNrAAIQgAAEINBJANHsBIUZBCAAAQhA4C8QQGAHAj8/P3+U+fv7+8+crZfn/yz+/wO/Xq7pvBbH1mxvGUN7yrHmQ7FLH0e2pV+d1/Zo7Uqe2sMIgZ0IIJo7dXvzWr3weBQtIZK92ZpNaed9+GO/z89fOZYPL3BlfK3J1vzbXGlXi6s93lb+avbMQQACfxPg61muhO0ISDCOCi9t7LycO9pfW7P9V4XpLGa5buflXJlLa13zNl7Ns4zBOQRWJcCb5qqdpa4mgSeCcLRXolPaaL6Z0MFC6evA9D9LR/ue5POfIJxAYEMCiOaGTd+1ZC8kd4WjZ5+38TGvcPf7vL9eH3f29PrGDgI7E0A0d+7+ZrV/ISR3Y97dt1lLKRcC0wkgmtORE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xlIWBCAAAQiMJ4BojmeKRwhAAAIQWJQAorloYykLAhCAAATGE0A0xzPFIwQgAAEILEoA0Vy0sZQFAQhAAALjCSCa45niEQIQgAAEFiWAaC7aWMqCAAQgAIHxBBDN8UzxCAEIQAACixL4a9G6KGshAvY/hG59ev9H0SN8tHKw+dJ/La8jG63V9h3F7VmTb9nWYngbv96aly9GCOxGgDfN3TqetF57kOth7o+vlOP3+eMrPo5se3y2bGz+zU8rrsWUMMpG5xrL+TfzxDcEohNANKN3iPz+EcsSxRWhadm25stYR+cmLt6PHUtwtK/HRrYjx964Pn+Lr/xb8yNzxBcEMhFANDN1i1wh8BIBiWTpvjVf2nEOgV0IIJq7dJo6IdAgoLdJE0gvkq35hhumIbAFAf4i0BZtpkgIHBOQQJqVCafONZbzx95YhcC6BHjTXLe3VDaJgAmLf0PzoqMUemxkO3K8GreWu+XTmh+ZK74gkIEAb5oZukSO/yEggfJvQf8x6DgZ4aMMI59+vhSbms2RvV97clyL63OrrVu81vyTXNgLgcwEfn6fPHkyV07uEDgg4AXlwIwlCEBgMwJ8PbtZwykXAhCAAATuE0A077NjJwQgAAEIbEYA0dys4ZQLAQhAAAL3CSCa99mxEwIQgAAENiOAaG7WcMqFAAQgAIH7BBDN++zYCQEIQAACmxFANDdrOOVCAAIQgMB9AojmfXbsXJgA//nyws2lNAg8IIBoPoDHVghAAAIQ2IsAorlXv6kWAhCAAAQeEEA0H8BjKwQgAAEI7EUA0dyr31QLAQhAAAIPCCCaD+CxFQIQgAAE9iKAaO7Vb6qFAAQgAIEHBP4fuImVdOKdXc4AAAAASUVORK5CYII=" alt="" /></span></div><div style="text-align: left;"><span style="font-size:18px;"></span></div><div style="text-align: left;"><span style="font-size:18px;"></span><pre name="code" class="plain">clear;clc;

N = 4;                        %四个节点 分别是cloudy,sprinkler,rain,wetgrass
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;
discrete_nodes = 1:N;         %离散节点
node_sizes = 2*ones(1,N);     %节点状态数
bnet =mk_bnet(dag,node_sizes,'names',{'cloudy',...
    'sprinkler','rain','wetgrass'},'discrete',discrete_nodes);
bnet.CPD{C} = tabular_CPD(bnet,C,[0.5 0.5]);        %手动输入条件概率
bnet.CPD{R} = tabular_CPD(bnet,R,[0.8 0.2 0.2 0.8]);
bnet.CPD{S} = tabular_CPD(bnet,S,[0.5 0.9 0.5 0.1]);
bnet.CPD{W} = tabular_CPD(bnet,W,[1 0.1 0.1 0.01 0 0.9 0.9 0.99]);

%画出建立好的贝叶斯网络
figure
draw_graph(dag);
<p style="margin-top: 0px; margin-bottom: 5px; padding-top: 0px; padding-bottom: 0px; border: 0px; list-style: none; word-wrap: normal; word-break: normal; line-height: 21px; color: rgb(50, 62, 50); font-family: simsun; font-size: 14px; background-color: rgb(216, 204, 224);"></p>
</pre><span style="color: rgb(50, 62, 50); font-family: simsun; font-size: 14px; line-height: 21px; background-color: rgb(216, 204, 224);"></span><pre name="code" class="plain">

      接下来比如我们想计算洒水器导致草地是湿润的概率。证据的构成是W=2,enter_evidenc 执行一个双通道的信息传递模式。第一次返回的变量包括修正的结合着证据的引擎,第二次返回的变量包括证据的对数似然。

按如下方式计算p=P(S=2|W=2):

</pre></p></div><div style="text-align: left;"><span style="font-size:18px;"></span><pre name="code" class="plain">
</pre><pre name="code" class="plain" style="font-size: 18px;">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 是你所需要计算的条件概率的条件部分,而marginal_nodes的第二个参数是你所需要的计算的条件概率的概率部分。由以上代码可以计算条件概率P(S|W=2)储存在变量marg.T里面。

      两个小例子:


一、直接计算p(W)概率
</pre><pre name="code" class="plain" style="font-size: 18px;">evidence = cell(1,N);
[engine, ll] = enter_evidence(engine, evidence);
m = marginal_nodes(engine, [W]);
m.T

二、计算联合概率
<p>evidence = cell(1,N);</p><p>[engine, ll] = enter_evidence(engine,evidence);</p><p>m = marginal_nodes(engine, [S R W]);</p>


本文在博客http://blog.sina.com.cn/s/blog_6c7b434d01013ufz.html基础上根据自己理解所写

------------------
祝身体健康,万事如意

华电北风吹

天津大学计算机科学与技术学院认知计算与应用重点实验室

天津市卫津路92号

邮编: 300072



文章来自:http://blog.csdn.net/zhangzhengyi03539/article/details/44036259
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3