Mercurial > hg > mauch-mirex-2010
annotate _FullBNT/BNT/learning/learn_params_dbn.m @ 9:4ea6619cb3f5 tip
removed log files
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:55:11 +0100 |
parents | b5b38998ef3b |
children |
rev | line source |
---|---|
matthiasm@8 | 1 function bnet = learn_params_dbn(bnet, data) |
matthiasm@8 | 2 % LEARN_PARAM_DBN Estimate params of a DBN for a fully observed model |
matthiasm@8 | 3 % bnet = learn_params_dbn(bnet, data) |
matthiasm@8 | 4 % |
matthiasm@8 | 5 % data(i,t) is the value of node i in slice t (can be a cell array) |
matthiasm@8 | 6 % We currently assume there is a single time series |
matthiasm@8 | 7 % |
matthiasm@8 | 8 % We set bnet.CPD{i} to its ML/MAP estimate. |
matthiasm@8 | 9 % |
matthiasm@8 | 10 % Currently we assume each node in the first 2 slices has its own CPD (no param tying); |
matthiasm@8 | 11 % all nodes in slices >2 share their params with slice 2 as usual. |
matthiasm@8 | 12 |
matthiasm@8 | 13 [ss T] = size(data); |
matthiasm@8 | 14 |
matthiasm@8 | 15 % slice 1 |
matthiasm@8 | 16 for j=1:ss |
matthiasm@8 | 17 if adjustable_CPD(bnet.CPD{j}) |
matthiasm@8 | 18 fam = family(bnet.dag,j); |
matthiasm@8 | 19 bnet.CPD{j} = learn_params(bnet.CPD{j}, data(fam,1)); |
matthiasm@8 | 20 end |
matthiasm@8 | 21 end |
matthiasm@8 | 22 |
matthiasm@8 | 23 |
matthiasm@8 | 24 % slices 2:T |
matthiasm@8 | 25 % data2(:,t) contains [data(:,t-1); data(:,t)]. |
matthiasm@8 | 26 % Then we extract out the rows corresponding to the parents in the current and previous slice. |
matthiasm@8 | 27 data2 = [data(:,1:T-1); |
matthiasm@8 | 28 data(:,2:T)]; |
matthiasm@8 | 29 for j=1:ss |
matthiasm@8 | 30 j2 = j+ss; |
matthiasm@8 | 31 if adjustable_CPD(bnet.CPD{j2}) |
matthiasm@8 | 32 fam = family(bnet.dag,j2); |
matthiasm@8 | 33 bnet.CPD{j2} = learn_params(bnet.CPD{j2}, data2(fam,:)); |
matthiasm@8 | 34 end |
matthiasm@8 | 35 end |
matthiasm@8 | 36 |