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