annotate toolboxes/FullBNT-1.0.7/HMM/dhmm_logprob_path.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [ll, p] = prob_path(prior, transmat, obsmat, qs)
wolffd@0 2 % PROB_PATH Compute the prob. of a specific path (state sequence) through an HMM.
wolffd@0 3 % [ll, p] = prob_path(prior, transmat, obsmat, states)
wolffd@0 4 %
wolffd@0 5 % ll = log prob path
wolffd@0 6 % p(t) = Pr(O(t)) * Pr(Q(t) -> Q(t+1)) for 1<=t<T, p(T) = Pr(O(T))
wolffd@0 7
wolffd@0 8 T = size(obsmat, 2);
wolffd@0 9 p = zeros(1,T);
wolffd@0 10 p(1) = prior(qs(1)) * obsmat(qs(1),1);
wolffd@0 11 for t=2:T
wolffd@0 12 p(t) = transmat(qs(t-1), qs(t)) * obsmat(qs(t),t);
wolffd@0 13 end
wolffd@0 14
wolffd@0 15 ll = sum(log(p));