comparison toolboxes/FullBNT-1.0.7/bnt/examples/static/Models/mk_cancer_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_cancer_bnet(CPD_type, p)
2 % MK_CANCER_BNET Make the 'Cancer' Bayes net.
3 %
4 % BNET = MK_CANCER_BNET uses the noisy-or parameters specified in Fig 4a of the UAI98 paper by
5 % Friedman, Murphy and Russell, "Learning the Structure of DPNs", p145.
6 %
7 % BNET = MK_CANCER_BNET('noisyor', p) makes each CPD a noisy-or, with probability p of
8 % suppression for each parent; leaks are turned off.
9 %
10 % BNET = MK_CANCER_BNET('cpt', p) uses random CPT parameters drawn from a Dirichlet(p,p,...)
11 % distribution. If p << 1, this is near deterministic; if p >> 1, this is near 1/k.
12 % p defaults to 1.0 (uniform distribution).
13 %
14 % BNET = MK_CANCER_BNET('bool') makes each CPT a random boolean function.
15 %
16 % In all cases, the root is set to a uniform distribution.
17
18 if nargin == 0
19 rnd = 0;
20 else
21 rnd = 1;
22 end
23
24 n = 5;
25 dag = zeros(n);
26 dag(1,[2 3]) = 1;
27 dag(2,4) = 1;
28 dag(3,4) = 1;
29 dag(4,5) = 1;
30
31 ns = 2*ones(1,n);
32 bnet = mk_bnet(dag, ns);
33
34 if ~rnd
35 bnet.CPD{1} = tabular_CPD(bnet, 1, [0.5 0.5]);
36 bnet.CPD{2} = noisyor_CPD(bnet, 2, 1.0, 1-0.9);
37 bnet.CPD{3} = noisyor_CPD(bnet, 3, 1.0, 1-0.2);
38 bnet.CPD{4} = noisyor_CPD(bnet, 4, 1.0, 1-[0.7 0.6]);
39 bnet.CPD{5} = noisyor_CPD(bnet, 5, 1.0, 1-0.5);
40 else
41 switch CPD_type
42 case 'noisyor',
43 for i=1:n
44 ps = parents(dag, i);
45 bnet.CPD{i} = noisyor_CPD(bnet, i, 1.0, p*ones(1,length(ps)));
46 end
47 case 'bool',
48 for i=1:n
49 bnet.CPD{i} = boolean_CPD(bnet, i, 'rnd');
50 end
51 case 'cpt',
52 for i=1:n
53 bnet.CPD{i} = tabular_CPD(bnet, i, p);
54 end
55 otherwise
56 error(['bad CPD type ' CPD_type]);
57 end
58 end
59
60
61