Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/HHMM/Old/remove_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 [transprob, termprob] = remove_hhmm_end_state(A) | |
2 % REMOVE_END_STATE Infer transition and termination probabilities from automaton with an end state | |
3 % [transprob, termprob] = remove_end_state(A) | |
4 % 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 | |
5 | |
6 if ndims(A)==2 % top level | |
7 Q = size(A,1); | |
8 transprob = A(:,1:Q); | |
9 termprob = A(:,Q+1)'; | |
10 | |
11 % rescale | |
12 for i=1:Q | |
13 for j=1:Q | |
14 denom = (1-termprob(i)); | |
15 denom = denom + (denom==0)*eps; | |
16 transprob(i,j) = transprob(i,j) / denom; | |
17 end | |
18 end | |
19 else | |
20 Q = size(A,1); | |
21 Qk = size(A,2); | |
22 transprob = A(:, :, 1:Q); | |
23 termprob = A(:,:,Q+1)'; | |
24 | |
25 % rescale | |
26 for k=1:Qk | |
27 for i=1:Q | |
28 for j=1:Q | |
29 denom = (1-termprob(k,i)); | |
30 denom = denom + (denom==0)*eps; | |
31 transprob(i,k,j) = transprob(i,k,j) / denom; | |
32 end | |
33 end | |
34 end | |
35 | |
36 end | |
37 |