annotate toolboxes/FullBNT-1.0.7/HMM/dhmm_logprob.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [loglik, errors] = dhmm_logprob(data, prior, transmat, obsmat)
wolffd@0 2 % LOG_LIK_DHMM Compute the log-likelihood of a dataset using a discrete HMM
wolffd@0 3 % [loglik, errors] = log_lik_dhmm(data, prior, transmat, obsmat)
wolffd@0 4 %
wolffd@0 5 % data{m} or data(m,:) is the m'th sequence
wolffd@0 6 % errors is a list of the cases which received a loglik of -infinity
wolffd@0 7
wolffd@0 8 if ~iscell(data)
wolffd@0 9 data = num2cell(data, 2);
wolffd@0 10 end
wolffd@0 11 ncases = length(data);
wolffd@0 12
wolffd@0 13 loglik = 0;
wolffd@0 14 errors = [];
wolffd@0 15 for m=1:ncases
wolffd@0 16 obslik = multinomial_prob(data{m}, obsmat);
wolffd@0 17 [alpha, beta, gamma, ll] = fwdback(prior, transmat, obslik, 'fwd_only', 1);
wolffd@0 18 if ll==-inf
wolffd@0 19 errors = [errors m];
wolffd@0 20 end
wolffd@0 21 loglik = loglik + ll;
wolffd@0 22 end