comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/mk_water_dbn.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_water_dbn(discrete_obs, obs_leaves)
2 % MK_WATER_DBN
3 % bnet = mk_water_dbn(discrete_obs, obs_leaves)
4 %
5 % If discrete_obs = 1 (default), the leaves are binary, else scalar Gaussians
6 % If obs_leaves = 1, all the leaves are observed, otherwise rnd nodes are observed
7 %
8 % This is a model of the biological processes of a water purification plant, developed
9 % by Finn V. Jensen, Uffe Kjærulff, Kristian G. Olesen, and Jan Pedersen.
10 % See http://www-nt.cs.berkeley.edu/home/nir/public_html/Repository/water.htm
11 % See also Boyen and Koller, "Tractable Inference for Complex Stochastic Processes", UAI98
12
13 if nargin < 1, discrete_obs = 1; end
14 if nargin < 1, obs_leaves = 1; end
15
16 ss = 12;
17 intra = zeros(ss);
18 intra(1,9) = 1;
19 intra(3,10) = 1;
20 intra(4,11) = 1;
21 intra(8,12) = 1;
22
23 inter = zeros(ss);
24 inter(1, [1 3]) = 1;
25 inter(2, [2 3 7]) = 1;
26 inter(3, [3 4 5]) = 1;
27 inter(4, [3 4 6]) = 1;
28 inter(5, [3 5 6]) = 1;
29 inter(6, [4 5 6]) = 1;
30 inter(7, [7 8]) = 1;
31 inter(8, [6 7 8]) = 1;
32
33 if obs_leaves
34 onodes = 9:12; % leaves
35 else
36 onodes = [1 5 9:12]; % throw in some other nodes
37 end
38 hnodes = 1:8;
39 if discrete_obs
40 ns = 2*ones(1 ,ss);
41 dnodes = 1:ss;
42 else
43 ns = [2*ones(1,length(hnodes)) 1*ones(length(onodes))];
44 dnodes = hnodes;
45 end
46
47 eclass1 = 1:12;
48 eclass2 = [13:20 9:12];
49 bnet = mk_dbn(intra, inter, ns, 'discrete', dnodes, 'eclass1', eclass1, 'eclass2', eclass2, ...
50 'observed', onodes);
51 if discrete_obs
52 for i=1:max(eclass2)
53 bnet.CPD{i} = tabular_CPD(bnet, i);
54 end
55 else
56 for i=hnodes(:)'
57 bnet.CPD{i} = tabular_CPD(bnet, i);
58 end
59 for i=onodes(:)'
60 bnet.CPD{i} = gaussian_CPD(bnet, i);
61 end
62 for i=hnodes(:)'+ss
63 bnet.CPD{i} = tabular_CPD(bnet, i);
64 end
65 end
66
67
68