annotate toolboxes/FullBNT-1.0.7/bnt/learning/learn_params.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function bnet = learn_params(bnet, data)
wolffd@0 2 % LEARN_PARAMS Find the maximum likelihood params for a fully observed model
wolffd@0 3 % bnet = learn_params(bnet, data)
wolffd@0 4 %
wolffd@0 5 % data(i,m) is the value of node i in case m (can be a cell array)
wolffd@0 6 %
wolffd@0 7 % We set bnet.CPD{i} to its ML/MAP estimate.
wolffd@0 8 %
wolffd@0 9 % Currently we assume no param tying
wolffd@0 10
wolffd@0 11 % AND THAT EACH DATA POINT IS A SCALAR - no longer assumed
wolffd@0 12
wolffd@0 13 %if iscell(data)
wolffd@0 14 % data=cell2num(data);
wolffd@0 15 %end
wolffd@0 16 [n ncases] = size(data);
wolffd@0 17 for j=1:n
wolffd@0 18 e = bnet.equiv_class(j);
wolffd@0 19 assert(e==j);
wolffd@0 20 if adjustable_CPD(bnet.CPD{e})
wolffd@0 21 fam = family(bnet.dag,j);
wolffd@0 22 %bnet.CPD{j} = learn_params(bnet.CPD{j}, data(fam,:));
wolffd@0 23 bnet.CPD{j} = learn_params(bnet.CPD{j}, fam, data, bnet.node_sizes, bnet.cnodes);
wolffd@0 24 end
wolffd@0 25 end
wolffd@0 26