annotate toolboxes/FullBNT-1.0.7/bnt/CPDs/@hhmm2Q_CPD/update_ess.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 CPD = update_ess(CPD, fmarginal, evidence, ns, cnodes, hidden_bitv)
wolffd@0 2
wolffd@0 3 marg = add_ev_to_dmarginal(fmarginal, evidence, ns);
wolffd@0 4
wolffd@0 5 nps = length(CPD.dom_sz)-1; % num parents
wolffd@0 6
wolffd@0 7 if ~isempty(CPD.Fbelow_ndx)
wolffd@0 8 if ~isempty(CPD.Fself_ndx) % general case
wolffd@0 9 ndx = mk_multi_index(nps+1, [CPD.Fbelow_ndx CPD.Fself_ndx], [2 1]);
wolffd@0 10 CPD.trans_counts = CPD.trans_counts + squeeze(marg.T(ndx{:}));
wolffd@0 11 ndx = mk_multi_index(nps+1, [CPD.Fbelow_ndx CPD.Fself_ndx], [2 2]);
wolffd@0 12 CPD.start_counts = CPD.start_counts + squeeze(marg.T(ndx{:}));
wolffd@0 13 else % no F from self, hence no startprob (top level)
wolffd@0 14 ndx = mk_multi_index(nps+1, CPD.Fbelow_ndx, 2);
wolffd@0 15 CPD.trans_counts = CPD.trans_counts + squeeze(marg.T(ndx{:}));
wolffd@0 16 end
wolffd@0 17 else % no F signal from below
wolffd@0 18 if ~isempty(CPD.Fself_ndx) % self F (bottom level)
wolffd@0 19 ndx = mk_multi_index(nps+1, CPD.Fself_ndx, 1);
wolffd@0 20 CPD.trans_counts = CPD.trans_counts + squeeze(marg.T(ndx{:}));
wolffd@0 21 ndx = mk_multi_index(nps+1, CPD.Fself_ndx, 2);
wolffd@0 22 CPD.start_counts = CPD.start_counts + squeeze(marg.T(ndx{:}));
wolffd@0 23 else % no F from self or below
wolffd@0 24 error('no F signal')
wolffd@0 25 end
wolffd@0 26 end