相关疑难解决方法(0)

在Matlab中构造多阶马尔可夫链转移矩阵

可以如下非常优雅构造 6个状态的一阶转移矩阵

 x = [1 6 1 6 4 4 4 3 1 2 2 3 4 5 4 5 2 6 2 6 2 6]; % the Markov chain
 tm = full(sparse(x(1:end-1),x(2:end),1)) % the transition matrix.
Run Code Online (Sandbox Code Playgroud)

所以这是我的问题,你如何优雅地构建二阶转移矩阵?我想出的解决方案如下

 [si sj] = ndgrid(1:6);
 s2 = [si(:) sj(:)]; % combinations for 2 contiguous states
 tm2 = zeros([numel(si),6]); % initialize transition matrix
 for i = 3:numel(x) % construct transition matrix
   tm2(strmatch(num2str(x(i-2:i-1)),num2str(s2)),x(i))=...
   tm2(strmatch(num2str(x(i-2:i-1)),num2str(s2)),x(i))+1;
 end
Run Code Online (Sandbox Code Playgroud)

是否有单/双线,无环替代?

-

编辑:我尝试将我的解决方案与Amro的比较与"x = round(5*rand([1,1000])+ 1);"

 % …
Run Code Online (Sandbox Code Playgroud)

matlab transition probability matrix markov-chains

8
推荐指数
1
解决办法
6055
查看次数

如何在MATLAB中从HMM的多序列中获得过渡和发射矩阵?

我正在使用HMM在MATLAB中进行序列分类任务.我有13个序列及其相应的类.据我所知,hmmestimate()返回一个序列及其类的转换和发射矩阵.但我需要从所有这13个序列计算的最终转换和发射矩阵.我该怎么做 ?

matlab training-data hidden-markov-models

5
推荐指数
1
解决办法
1374
查看次数