comparison toolboxes/FullBNT-1.0.7/bnt/learning/learn_params_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 = learn_params_dbn(bnet, data)
2 % LEARN_PARAM_DBN Estimate params of a DBN for a fully observed model
3 % bnet = learn_params_dbn(bnet, data)
4 %
5 % data(i,t) is the value of node i in slice t (can be a cell array)
6 % We currently assume there is a single time series
7 %
8 % We set bnet.CPD{i} to its ML/MAP estimate.
9 %
10 % Currently we assume each node in the first 2 slices has its own CPD (no param tying);
11 % all nodes in slices >2 share their params with slice 2 as usual.
12
13 [ss T] = size(data);
14
15 % slice 1
16 for j=1:ss
17 if adjustable_CPD(bnet.CPD{j})
18 fam = family(bnet.dag,j);
19 bnet.CPD{j} = learn_params(bnet.CPD{j}, data(fam,1));
20 end
21 end
22
23
24 % slices 2:T
25 % data2(:,t) contains [data(:,t-1); data(:,t)].
26 % Then we extract out the rows corresponding to the parents in the current and previous slice.
27 data2 = [data(:,1:T-1);
28 data(:,2:T)];
29 for j=1:ss
30 j2 = j+ss;
31 if adjustable_CPD(bnet.CPD{j2})
32 fam = family(bnet.dag,j2);
33 bnet.CPD{j2} = learn_params(bnet.CPD{j2}, data2(fam,:));
34 end
35 end
36