Daniel@0: function bnet = learn_params(bnet, data) Daniel@0: % LEARN_PARAMS Find the maximum likelihood params for a fully observed model Daniel@0: % bnet = learn_params(bnet, data) Daniel@0: % Daniel@0: % data(i,m) is the value of node i in case m (can be a cell array) Daniel@0: % Daniel@0: % We set bnet.CPD{i} to its ML/MAP estimate. Daniel@0: % Daniel@0: % Currently we assume no param tying Daniel@0: Daniel@0: % AND THAT EACH DATA POINT IS A SCALAR - no longer assumed Daniel@0: Daniel@0: %if iscell(data) Daniel@0: % data=cell2num(data); Daniel@0: %end Daniel@0: [n ncases] = size(data); Daniel@0: for j=1:n Daniel@0: e = bnet.equiv_class(j); Daniel@0: assert(e==j); Daniel@0: if adjustable_CPD(bnet.CPD{e}) Daniel@0: fam = family(bnet.dag,j); Daniel@0: %bnet.CPD{j} = learn_params(bnet.CPD{j}, data(fam,:)); Daniel@0: bnet.CPD{j} = learn_params(bnet.CPD{j}, fam, data, bnet.node_sizes, bnet.cnodes); Daniel@0: end Daniel@0: end Daniel@0: