mhmm_em_demo.m

来自「详细介绍了隐马尔科夫链的原理和matlab代码实现」· M 代码 · 共 41 行

M
41
字号
if 1  O = 4;  T = 10;  nex = 50;  M = 2;  Q = 3;else  O = 8;          %Number of coefficients in a vector   T = 420;         %Number of vectors in a sequence   nex = 1;        %Number of sequences   M = 1;          %Number of mixtures   Q = 6;          %Number of states endcov_type = 'full';data = randn(O,T,nex);% initial guess of parametersprior0 = normalise(rand(Q,1));transmat0 = mk_stochastic(rand(Q,Q));if 0  Sigma0 = repmat(eye(O), [1 1 Q M]);  % Initialize each mean to a random data point  indices = randperm(T*nex);  mu0 = reshape(data(:,indices(1:(Q*M))), [O Q M]);  mixmat0 = mk_stochastic(rand(Q,M));else  [mu0, Sigma0] = mixgauss_init(Q*M, data, cov_type);  mu0 = reshape(mu0, [O Q M]);  Sigma0 = reshape(Sigma0, [O O Q M]);  mixmat0 = mk_stochastic(rand(Q,M));end[LL, prior1, transmat1, mu1, Sigma1, mixmat1] = ...    mhmm_em(data, prior0, transmat0, mu0, Sigma0, mixmat0, 'max_iter', 5);loglik = mhmm_logprob(data, prior1, transmat1, mu1, Sigma1, mixmat1);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?