about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m
diff options
context:
space:
mode:
authorziejd22017-09-28 15:04:40 -0500
committerziejd22017-09-28 15:04:40 -0500
commit8070dc963753142bb86c4ed698d91fd623ed28e7 (patch)
treed0f6dd8fc46a49b819aa55c1a90faa14d8448883 /sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m
parent7cc31810d53176e805532b2789955f4eedbce6bb (diff)
downloadBNW-8070dc963753142bb86c4ed698d91fd623ed28e7.tar.gz
BNW using Octave instead of Matlab.
This version of BNW should perform the same as the original version. The only difference is that it uses Octave instead of Matlab when running BayesNet Toolbox during parameter learning.

I am calling this BNW_1.02. It can be accessed at:
compbio.uthsc.edu/BNW_1.02
Diffstat (limited to 'sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m')
-rw-r--r--sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m61
1 files changed, 61 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m b/sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m
new file mode 100644
index 00000000..c54cbfad
--- /dev/null
+++ b/sourcecodes/bnt-master/BNT/examples/static/Models/mk_cancer_bnet.m
@@ -0,0 +1,61 @@
+function bnet = mk_cancer_bnet(CPD_type, p)
+% MK_CANCER_BNET Make the 'Cancer' Bayes net.
+%
+% BNET = MK_CANCER_BNET uses the noisy-or parameters specified in Fig 4a of the UAI98 paper by
+% Friedman, Murphy and Russell, "Learning the Structure of DPNs", p145.
+%
+% BNET = MK_CANCER_BNET('noisyor', p) makes each CPD a noisy-or, with probability p of
+% suppression for each parent; leaks are turned off.
+%
+% BNET = MK_CANCER_BNET('cpt', p) uses random CPT parameters drawn from a Dirichlet(p,p,...)
+% distribution. If p << 1, this is near deterministic; if p >> 1, this is near 1/k.
+% p defaults to 1.0 (uniform distribution).
+%
+% BNET = MK_CANCER_BNET('bool') makes each CPT a random boolean function.
+%
+% In all cases, the root is set to a uniform distribution.
+
+if nargin == 0
+  rnd = 0;
+else
+  rnd = 1;
+end
+
+n = 5;
+dag = zeros(n);
+dag(1,[2 3]) = 1;
+dag(2,4) = 1;
+dag(3,4) = 1;
+dag(4,5) = 1;
+
+ns = 2*ones(1,n);
+bnet = mk_bnet(dag, ns);
+    
+if ~rnd
+  bnet.CPD{1} = tabular_CPD(bnet, 1, [0.5 0.5]);
+  bnet.CPD{2} = noisyor_CPD(bnet, 2, 1.0, 1-0.9);
+  bnet.CPD{3} = noisyor_CPD(bnet, 3, 1.0, 1-0.2);
+  bnet.CPD{4} = noisyor_CPD(bnet, 4, 1.0, 1-[0.7 0.6]);
+  bnet.CPD{5} = noisyor_CPD(bnet, 5, 1.0, 1-0.5);
+else
+  switch CPD_type
+   case 'noisyor',
+    for i=1:n
+      ps = parents(dag, i);
+      bnet.CPD{i} = noisyor_CPD(bnet, i, 1.0, p*ones(1,length(ps)));
+    end
+   case 'bool',
+    for i=1:n
+      bnet.CPD{i} = boolean_CPD(bnet, i, 'rnd');
+    end
+   case 'cpt',
+    for i=1:n
+      bnet.CPD{i} = tabular_CPD(bnet, i, p);
+    end
+   otherwise
+    error(['bad CPD type ' CPD_type]);
+  end
+end
+  
+  
+