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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function bnet = learn_params(bnet, data)
Daniel@0 2 % LEARN_PARAMS Find the maximum likelihood params for a fully observed model
Daniel@0 3 % bnet = learn_params(bnet, data)
Daniel@0 4 %
Daniel@0 5 % data(i,m) is the value of node i in case m (can be a cell array)
Daniel@0 6 %
Daniel@0 7 % We set bnet.CPD{i} to its ML/MAP estimate.
Daniel@0 8 %
Daniel@0 9 % Currently we assume no param tying
Daniel@0 10
Daniel@0 11 % AND THAT EACH DATA POINT IS A SCALAR - no longer assumed
Daniel@0 12
Daniel@0 13 %if iscell(data)
Daniel@0 14 % data=cell2num(data);
Daniel@0 15 %end
Daniel@0 16 [n ncases] = size(data);
Daniel@0 17 for j=1:n
Daniel@0 18 e = bnet.equiv_class(j);
Daniel@0 19 assert(e==j);
Daniel@0 20 if adjustable_CPD(bnet.CPD{e})
Daniel@0 21 fam = family(bnet.dag,j);
Daniel@0 22 %bnet.CPD{j} = learn_params(bnet.CPD{j}, data(fam,:));
Daniel@0 23 bnet.CPD{j} = learn_params(bnet.CPD{j}, fam, data, bnet.node_sizes, bnet.cnodes);
Daniel@0 24 end
Daniel@0 25 end
Daniel@0 26