% A demonstration of the HMM software using a Gaussian observation% model on AR featuresload demgaussT=size(arp,1);% X original time series% arp AR(4) featuresplot(X);title('Original data');disp('The middle section of data is mainly 10Hz activity');disp('wheras the beginning and end sections are just noise');disp(' ');disp('Press a key to continue');pausedisp(' ');disp('We will train a Gaussian Mixture Model on AR-4 features derived from');disp('overlapping blocks of the time series.');disp('The resulting GMM will be used to initialise an HMM.');disp(' ');disp('Press a key to continue');pause% Train up GMM on this datahmm.K=2;disp(' ');hmm=hmminit(arp,hmm,'diag');disp('Means of HMM initialisation');hmm.state(1).Muhmm.state(2).Mu% Train up HMM on observation sequence data using Baum-Welch% This uses the forward-backward method as a sub-routinedisp('We will now train the HMM using Baum/Welch');disp(' ');disp('Press a key to continue');pausedisp('Estimated HMM');hmm.train.cyc=30;hmm.obsmodel='Gauss';hmm.train.obsupdate=ones(1,hmm.K); % update observation models ?hmm.train.init=1; % Yes, we've already done initialisationhmm=hmmtrain(arp,T,hmm);disp('Means');hmm.state(1).Muhmm.state(2).Mudisp('Initial State Probabilities, Pi');hmm.Pidisp('State Transition Matrix, P');hmm.P[block]=hmmdecode(arp,T,hmm);% Find most likely hidden state sequence using Viterbi methodfigureplot(block(1).q_star);axis([0 T 0 3]);title('Viterbi decoding');disp('The Viterbi decoding plot shows that the time series');disp('has been correctly partitioned.');
matlab hmm 计算最大路径,demgausshmm.m 源代码在线查看 - Matlab 马尔科夫计算工具包 资源下载 虫虫电子下载站...
最新推荐文章于 2022-04-22 23:51:06 发布