comparison toolboxes/FullBNT-1.0.7/HMM/dhmm_em_demo.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 O = 3;
2 Q = 2;
3
4 % "true" parameters
5 prior0 = normalise(rand(Q,1));
6 transmat0 = mk_stochastic(rand(Q,Q));
7 obsmat0 = mk_stochastic(rand(Q,O));
8
9 % training data
10 T = 5;
11 nex = 10;
12 data = dhmm_sample(prior0, transmat0, obsmat0, T, nex);
13
14 % initial guess of parameters
15 prior1 = normalise(rand(Q,1));
16 transmat1 = mk_stochastic(rand(Q,Q));
17 obsmat1 = mk_stochastic(rand(Q,O));
18
19 % improve guess of parameters using EM
20 [LL, prior2, transmat2, obsmat2] = dhmm_em(data, prior1, transmat1, obsmat1, 'max_iter', 5);
21 LL
22
23 % use model to compute log likelihood
24 loglik = dhmm_logprob(data, prior2, transmat2, obsmat2)
25 % log lik is slightly different than LL(end), since it is computed after the final M step