⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mk_asia_bnet.m

📁 基于贝叶斯网络的源程序
💻 M
字号:
function bnet = mk_asia_bnet(CPD_type, p, arity)% MK_ASIA_BNET Make the 'Asia' bayes net.%% BNET = MK_ASIA_BNET uses the parameters specified on p21 of Cowell et al, % "Probabilistic networks and expert systems", Springer Verlag 1999.% % BNET = MK_ASIA_BNET('cpt', p) uses random parameters drawn from a Dirichlet(p,p,...)% distribution. If p << 1, this is nearly deterministic; if p >> 1, this is nearly uniform.% % BNET = MK_ASIA_BNET('bool') makes each CPT a random boolean function.%% BNET = MK_ASIA_BNET('gauss') makes each CPT a random linear Gaussian distribution.%% BNET = MK_ASIA_BNET('orig') is the same as MK_ASIA_BNET.%% BNET = MK_ASIA_BNET('cpt', p, arity) can specify non-binary nodes.if nargin == 0, CPD_type = 'orig'; endif nargin < 3, arity = 2; endSmoking = 1;Bronchitis = 2;LungCancer = 3;VisitToAsia = 4;TB = 5;TBorCancer = 6;Dys = 7;Xray = 8;n = 8;dag = zeros(n);dag(Smoking, [Bronchitis LungCancer]) = 1;dag(Bronchitis, Dys) = 1;dag(LungCancer, TBorCancer) = 1;dag(VisitToAsia, TB) = 1;dag(TB, TBorCancer) = 1;dag(TBorCancer, [Dys Xray]) = 1;ns = arity*ones(1,n);if strcmp(CPD_type, 'gauss')  dnodes = [];else  dnodes = 1:n;endbnet = mk_bnet(dag, ns, 'discrete', dnodes);switch CPD_type case 'orig',   bnet.CPD{VisitToAsia} = tabular_CPD(bnet, VisitToAsia, [0.99   0.01]);  bnet.CPD{Bronchitis} = tabular_CPD(bnet, Bronchitis, [0.7 0.4   0.3 0.6]);  bnet.CPD{Dys} = tabular_CPD(bnet, Dys, [0.8 0.2 0.3 0.1   0.1 0.8 0.7 0.9]);  bnet.CPD{TBorCancer} = tabular_CPD(bnet, TBorCancer, [1 0 0 0   0 1 1 1]);  bnet.CPD{LungCancer} = tabular_CPD(bnet, LungCancer, [0.99 0.9  0.01 01.]);  bnet.CPD{Smoking} = tabular_CPD(bnet, Smoking, [0.5 0.5]);  bnet.CPD{TB} = tabular_CPD(bnet, TB, [0.99 0.95  0.01 0.05]);  bnet.CPD{Xray} = tabular_CPD(bnet, Xray, [0.95 0.02  0.05 0.98]); case 'bool',  for i=1:n    bnet.CPD{i} = boolean_CPD(bnet, i, 'rnd');  end case 'gauss',  for i=1:n    bnet.CPD{i} = gaussian_CPD(bnet, i, 'cov', 1*eye(ns(i)));  end case 'cpt',  for i=1:n    bnet.CPD{i} = tabular_CPD(bnet, i, p);  endend    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -