view toolboxes/FullBNT-1.0.7/HMM/dhmm_logprob_brute_force.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
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)