Skip to content

Commit

Permalink
fix hmm demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Mar 10, 2017
1 parent 9e70e29 commit 4db85d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chapter13/HMM/hmmEm.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
% M-step
s = gamma(:,1); % 13.18
A = normalize(A.*(alpha(:,1:n-1)*(beta(:,2:n).*M(:,2:n)./c(2:n))'),2); % 13.19 13.43 13.65
E = bsxfun(@times,gamma*X',1./sum(gamma,2)); % 13.23
E = (gamma*X')./sum(gamma,2); % 13.23
end
model.s = s;
model.A = A;
Expand Down
3 changes: 2 additions & 1 deletion demo/ch13/hmm_demo.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
d = 3;
k = 2;
n = 10000;
[x,model] = hmmRnd(d,k,n);
%% Viterbi algorithm
[z, llh] = hmmViterbi(model, x);
%% HMM filter (forward algorithm)
[alpha, llh] = hmmFilter(model, x);
%% HMM smoother (forward backward)
[gamma,alpha,beta,c] = hmmSmoother(model, x);
%% Baum-Welch algorithm
[model, llh] = hmmEm(x,init);
[model, llh] = hmmEm(x,2);
plot(llh)

0 comments on commit 4db85d6

Please sign in to comment.