To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _FullBNT / BNT / CPDs / @hhmm2Q_CPD / update_ess.m @ 8:b5b38998ef3b

History | View | Annotate | Download (1.09 KB)

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