comparison toolboxes/FullBNT-1.0.7/HMM/mhmm_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 if 1
2 O = 4;
3 T = 10;
4 nex = 50;
5 M = 2;
6 Q = 3;
7 else
8 O = 8; %Number of coefficients in a vector
9 T = 420; %Number of vectors in a sequence
10 nex = 1; %Number of sequences
11 M = 1; %Number of mixtures
12 Q = 6; %Number of states
13 end
14 cov_type = 'full';
15
16 data = randn(O,T,nex);
17
18 % initial guess of parameters
19 prior0 = normalise(rand(Q,1));
20 transmat0 = mk_stochastic(rand(Q,Q));
21
22 if 0
23 Sigma0 = repmat(eye(O), [1 1 Q M]);
24 % Initialize each mean to a random data point
25 indices = randperm(T*nex);
26 mu0 = reshape(data(:,indices(1:(Q*M))), [O Q M]);
27 mixmat0 = mk_stochastic(rand(Q,M));
28 else
29 [mu0, Sigma0] = mixgauss_init(Q*M, data, cov_type);
30 mu0 = reshape(mu0, [O Q M]);
31 Sigma0 = reshape(Sigma0, [O O Q M]);
32 mixmat0 = mk_stochastic(rand(Q,M));
33 end
34
35 [LL, prior1, transmat1, mu1, Sigma1, mixmat1] = ...
36 mhmm_em(data, prior0, transmat0, mu0, Sigma0, mixmat0, 'max_iter', 5);
37
38
39 loglik = mhmm_logprob(data, prior1, transmat1, mu1, Sigma1, mixmat1);
40