annotate toolboxes/FullBNT-1.0.7/HMM/dhmm_logprob_path.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
rev   line source
Daniel@0 1 function [ll, p] = prob_path(prior, transmat, obsmat, qs)
Daniel@0 2 % PROB_PATH Compute the prob. of a specific path (state sequence) through an HMM.
Daniel@0 3 % [ll, p] = prob_path(prior, transmat, obsmat, states)
Daniel@0 4 %
Daniel@0 5 % ll = log prob path
Daniel@0 6 % p(t) = Pr(O(t)) * Pr(Q(t) -> Q(t+1)) for 1<=t<T, p(T) = Pr(O(T))
Daniel@0 7
Daniel@0 8 T = size(obsmat, 2);
Daniel@0 9 p = zeros(1,T);
Daniel@0 10 p(1) = prior(qs(1)) * obsmat(qs(1),1);
Daniel@0 11 for t=2:T
Daniel@0 12 p(t) = transmat(qs(t-1), qs(t)) * obsmat(qs(t),t);
Daniel@0 13 end
Daniel@0 14
Daniel@0 15 ll = sum(log(p));