Daniel@0: function logp = enumerate_HMM_loglik(prior, transmat, obsmat) Daniel@0: % ENUMERATE_HMM_LOGLIK Compute the log likelihood of a sequence by exhaustive (O(Q^T)) enumeration. Daniel@0: % logp = enumerate_HMM_loglik(prior, transmat, obsmat) Daniel@0: % Daniel@0: % Inputs: Daniel@0: % prior(i) = Pr(Q(1) = i) Daniel@0: % transmat(i,j) = Pr(Q(t+1)=j | Q(t)=i) Daniel@0: % obsmat(i,t) = Pr(y(t) | Q(t)=i) Daniel@0: Daniel@0: Q = length(prior); Daniel@0: T = size(obsmat, 2); Daniel@0: sizes = repmat(Q, 1, T); Daniel@0: Daniel@0: psum = 0; Daniel@0: for i=1:Q^T Daniel@0: qs = ind2subv(sizes, i); % make the state sequence Daniel@0: psum = psum + prob_path(prior, transmat, obsmat, qs); Daniel@0: end Daniel@0: logp = log(psum) Daniel@0: Daniel@0: