comparison toolboxes/FullBNT-1.0.7/bnt/inference/dynamic/@bk_ff_hmm_inf_engine/private/mk_hmm_obs_lik_vec.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 obslik = mk_hmm_obs_lik_vec(bnet, evidence)
2 % MK_HMM_OBS_LIK_VEC Make the observation likelihood vector for one slice
3 % obslik = mk_obs_lik(bnet, evidence)
4 %
5 % obslik(i) = Pr(y(t) | X(t)=i)
6 % evidence{i,1} contains the evidence on node i in slice t-1
7 % evidence{i,2} contains the evidence on node i in slice t
8
9 ns = bnet.node_sizes;
10 ss = length(bnet.intra);
11 onodes = find(~isemptycell(evidence(:)));
12 hnodes = find(isemptycell(evidence(:)));
13 ens = ns;
14 ens(onodes) = 1;
15 Q = prod(ens(hnodes));
16 obslik = zeros(1,Q);
17 dom = (1:ss)+ss;
18 bigpot = dpot(dom, ens(dom));
19 onodes1 = find(~isemptycell(evidence(:,1)));
20 for i=onodes1(:)'
21 e = bnet.equiv_class(i,2);
22 fam = family(bnet.dag, i, 2);
23 pot = convert_to_pot(bnet.CPD{e}, 'd', fam, evidence);
24 bigpot = multiply_by_pot(bigpot, pot);
25 end
26 m = pot_to_marginal(bigpot);
27 obslik = m.T(:);