hmmdemo.m

来自「连续隐马尔可夫模型hmm的matlab程序」· M 代码 · 共 49 行

M
49
字号
echo on;clc;% load and plot data on geyser eruption durations and waiting timesload geyser;                                                                clf; subplot(211);plot(geyser(:,1),geyser(:,2),'o');  xlabel('dur'); ylabel('wait time');axis('square'); hold on;% Hit any key to continue pause;clc;% divide up datasetXtrain=geyser(1:200,:); Xtest=geyser(201:295,:);% train HMM with 3 states for 30 cycles of EM or until convergence[Mu,Cov,P,Pi,LL]=hmm(Xtrain,200,3,30); % plot log likelihood (log L) per samplesubplot(212);plot(LL/200);                          ylabel('Log likelihood per sample'); xlabel('Iterations of EM'); hold on;% calculate log L for test datalik=hmm_cl(Xtest,95,3,Mu,Cov,P,Pi);  plot(length(LL),lik/95,'go');% examine state transition matrix and plot meansP                   subplot(211);plot(Mu(:,1),Mu(:,2),'r*');echo off;hold off;

⌨️ 快捷键说明

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