Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/HHMM/add_hhmm_end_state.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 A = add_hhmm_end_state(transprob, termprob) | |
2 % ADD_HMM_END_STATE Combine trans and term probs into transmat for automaton with an end state | |
3 % function A = add_hhmm_end_state(transprob, termprob) | |
4 % | |
5 % A(i,k,j) = Pr( i->j | Qps=k), where i in 1:Q, j in 1:(Q+1), and Q+1 is the end state | |
6 % This implements the equation in sec 4.6 of my tech report, where | |
7 % transprob(i,k,j) = \tilde{A}_k(i,j), termprob(k,j) = \tau_k(j) | |
8 % | |
9 % For the top level, the k index is missing. | |
10 | |
11 Q = size(transprob,1); | |
12 toplevel = (ndims(transprob)==2); | |
13 if toplevel | |
14 Qk = 1; | |
15 transprob = reshape(transprob, [Q 1 Q]); | |
16 termprob = reshape(termprob, [1 Q]); | |
17 else | |
18 Qk = size(transprob, 2); | |
19 end | |
20 | |
21 A = zeros(Q, Qk, Q+1); | |
22 A(:,:,Q+1) = termprob'; | |
23 | |
24 for k=1:Qk | |
25 for i=1:Q | |
26 for j=1:Q | |
27 A(i,k,j) = transprob(i,k,j) * (1-termprob(k,i)); | |
28 end | |
29 end | |
30 end | |
31 | |
32 if toplevel | |
33 A = squeeze(A); | |
34 end |