annotate toolboxes/FullBNT-1.0.7/bnt/examples/static/Models/mk_qmr_bnet.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function bnet = mk_qmr_bnet(G, inhibit, leak, prior, tabular_findings, onodes)
wolffd@0 2 % MK_QMR_BNET Make a QMR model
wolffd@0 3 % bnet = mk_qmr_bnet(G, inhibit, leak, prior)
wolffd@0 4 %
wolffd@0 5 % G(i,j) = 1 iff there is an arc from disease i to finding j
wolffd@0 6 % inhibit(i,j) = inhibition probability on i->j arc
wolffd@0 7 % leak(j) = inhibition prob. on leak->j arc
wolffd@0 8 % prior(i) = prob. disease i is on
wolffd@0 9 % tabular_findings = 1 means multinomial leaves (ignores leak/inhibit params)
wolffd@0 10 % = 0 means noisy-OR leaves (default = 0)
wolffd@0 11
wolffd@0 12 if nargin < 5, tabular_findings = 0; end
wolffd@0 13
wolffd@0 14 [Ndiseases Nfindings] = size(inhibit);
wolffd@0 15 N = Ndiseases + Nfindings;
wolffd@0 16 finding_node = Ndiseases+1:N;
wolffd@0 17 ns = 2*ones(1,N);
wolffd@0 18 dag = zeros(N,N);
wolffd@0 19 dag(1:Ndiseases, finding_node) = G;
wolffd@0 20 if nargin < 6, onodes = finding_node; end
wolffd@0 21 bnet = mk_bnet(dag, ns, 'observed', onodes);
wolffd@0 22
wolffd@0 23 for d=1:Ndiseases
wolffd@0 24 CPT = [1-prior(d) prior(d)];
wolffd@0 25 bnet.CPD{d} = tabular_CPD(bnet, d, CPT');
wolffd@0 26 end
wolffd@0 27
wolffd@0 28 for i=1:Nfindings
wolffd@0 29 fnode = finding_node(i);
wolffd@0 30 ps = parents(G, i);
wolffd@0 31 if tabular_findings
wolffd@0 32 bnet.CPD{fnode} = tabular_CPD(bnet, fnode);
wolffd@0 33 else
wolffd@0 34 bnet.CPD{fnode} = noisyor_CPD(bnet, fnode, leak(i), inhibit(ps, i));
wolffd@0 35 end
wolffd@0 36 end
wolffd@0 37
wolffd@0 38
wolffd@0 39
wolffd@0 40
wolffd@0 41