📄 hmmdemo.m
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -