annotate toolboxes/FullBNT-1.0.7/HMM/dhmm_logprob_brute_force.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 logp = enumerate_HMM_loglik(prior, transmat, obsmat)
wolffd@0 2 % ENUMERATE_HMM_LOGLIK Compute the log likelihood of a sequence by exhaustive (O(Q^T)) enumeration.
wolffd@0 3 % logp = enumerate_HMM_loglik(prior, transmat, obsmat)
wolffd@0 4 %
wolffd@0 5 % Inputs:
wolffd@0 6 % prior(i) = Pr(Q(1) = i)
wolffd@0 7 % transmat(i,j) = Pr(Q(t+1)=j | Q(t)=i)
wolffd@0 8 % obsmat(i,t) = Pr(y(t) | Q(t)=i)
wolffd@0 9
wolffd@0 10 Q = length(prior);
wolffd@0 11 T = size(obsmat, 2);
wolffd@0 12 sizes = repmat(Q, 1, T);
wolffd@0 13
wolffd@0 14 psum = 0;
wolffd@0 15 for i=1:Q^T
wolffd@0 16 qs = ind2subv(sizes, i); % make the state sequence
wolffd@0 17 psum = psum + prob_path(prior, transmat, obsmat, qs);
wolffd@0 18 end
wolffd@0 19 logp = log(psum)
wolffd@0 20
wolffd@0 21