hmm算法matlab实现和实例

时间:2014-10-29 10:35:25
【文件属性】:

文件名称:hmm算法matlab实现和实例

文件大小:24KB

文件格式:TXT

更新时间:2014-10-29 10:35:25

hmm

hmm算法matlab实现和实例 hmm_em.m function [LL, prior, transmat, obsmat, nrIterations] = ... dhmm_em(data, prior, transmat, obsmat, varargin) % LEARN_DHMM Find the ML/MAP parameters of an HMM with discrete outputs using EM. % [ll_trace, prior, transmat, obsmat, iterNr] = learn_dhmm(data, prior0, transmat0, obsmat0, ...) % % Notation: Q(t) = hidden state, Y(t) = observation % % INPUTS: % data{ex} or data(ex,:) if all sequences have the same length % prior(i) % transmat(i,j) % obsmat(i,o) % % Optional parameters may be passed as 'param_name', param_value pairs. % Parameter names are shown below; default values in [] - if none, argument is mandatory. % % 'max_iter' - max number of EM iterations [10] % 'thresh' - convergence threshold [1e-4] % 'verbose' - if 1, print out loglik at every iteration [1] % 'obs_prior_weight' - weight to apply to uniform dirichlet prior on observation matrix [0] % % To clamp some of the parameters, so learning does not change them: % 'adj_prior' - if 0, do not change prior [1] % 'adj_trans' - if 0, do not change transmat [1] % 'adj_obs' - if 0, do not change obsmat [1] % % Modified by Herbert Jaeger so xi are not computed individually % but only their sum (over time) as xi_summed; this is the only way how they are used % and it saves a lot of memory. [max_iter, thresh, verbose, obs_prior_weight, adj_prior, adj_trans, adj_obs] = ... process_options(varargin, 'max_iter', 10, 'thresh', 1e-4, 'verbose', 1, ... 'obs_prior_weight', 0, 'adj_prior', 1, 'adj_trans', 1, 'adj_obs', 1); previous_loglik = -inf; loglik = 0; converged = 0; num_iter = 1; LL = []; if ~iscell(data) data = num2cell(data, 2); % each row gets its own cell end while (num_iter <= max_iter) & ~converged % E step [loglik, exp_num_trans, exp_num_visits1, exp_num_emit] = ... compute_ess_dhmm(prior, transmat, obsmat, data, obs_prior_weight); % M step if adj_prior prior = normalise(exp_num_visits1); end if adj_trans & ~isempty(exp_num_trans) transmat = mk_stochastic(exp_num_trans); end if adj_obs obsmat = mk_stochastic(exp_num_emit); end


网友评论

  • 还可以,可以运行
  • 函数太多 很难看懂
  • 要理解得要窝在小黑屋里看几天吧,应该分开为.m格式的。
  • 没有注释,学习起来费劲
  • 我现在一些算法还看不太懂,不过还是值的借鉴的
  • 还行吧,可以运行
  • 可以运行,能看懂,挺好
  • 比较原始,理解需要下点功夫
  • 没有中文注释,看不懂呀。。。。。
  • 就是没有中文注释,难得看懂。
  • 问题是刚开始学 里面的介绍太少了 而且运行有点小问题
  • 对于初学者来说还是比较困难啊,注释能不能在详细一点
  • 看起来好像有点费劲,不过还有事参考作用的
  • 没有注释,学习起来费劲~
  • 不错,可以运行,就是看不懂
  • 所谓训练就是代入一个函数,但是还是没有说明那个训练集如何得来的!