adding
[mlfp.git] / matlab / model_likelihood.m
blob92a5f6e08cc9b814c35c412c1e9ff83a542c8b92
1 % To compute the model likelihood for a single observation, we add together\r
2 % the probabilities of each of the underlying Markov Chains multiplied by\r
3 % their priors.\r
4 function likelihood = model_likelihood(observation, model)\r
5 likelihood = 0;\r
6 likelihood_vect = zeros(model.num_mcs, 1);\r
7 for i=1:model.num_mcs\r
8     likelihood_vect(i) = model.priors(i) * chain_likelihood(observation, model.chain(i));\r
9 end\r
10 likelihood_vect;\r
11 likelihood = sum(likelihood_vect);\r
13 % The likelihood of the observation for a single Markov Chain\r
14 %function likelihood = chain_likelihood(observation, mc)\r
15 %ikelihood = mc.t(observation(1));\r
16 %for i=2:size(observation, 2)\r
17 %    likelihood = likelihood * mc.T(observation(i-1), observation(i));\r
18 %end