view 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
line wrap: on
line source
function logp = enumerate_HMM_loglik(prior, transmat, obsmat)
% ENUMERATE_HMM_LOGLIK Compute the log likelihood of a sequence by exhaustive (O(Q^T)) enumeration.
% logp = enumerate_HMM_loglik(prior, transmat, obsmat)
%
% Inputs:
% prior(i) = Pr(Q(1) = i)
% transmat(i,j) = Pr(Q(t+1)=j | Q(t)=i)
% obsmat(i,t) = Pr(y(t) | Q(t)=i)

Q = length(prior);
T = size(obsmat, 2);
sizes = repmat(Q, 1, T);

psum = 0;
for i=1:Q^T
  qs = ind2subv(sizes, i); % make the state sequence 
  psum = psum + prob_path(prior, transmat, obsmat, qs);
end
logp = log(psum)