adding
[mlfp.git] / matlab / chain_log_likelihood.m
blob788a2634339033683dbc9cd882085374a32d0c33
1 % The likelihood of the observation for a single Markov Chain\r
2 function likelihood = chain_log_likelihood(observation, mc)\r
3 likelihood = log(mc.t(observation(1)));\r
4 n = size(observation, 2);\r
5 for i=2:n\r
6     likelihood = likelihood + log(mc.T(observation(i-1), observation(i)));\r
7 end\r
8 \r
9 end_state = size(mc.T, 2);\r
10 % Add in the stop probability\r
11 likelihood = likelihood + log(mc.T(observation(n), end_state));