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