필터 지우기
필터 지우기

First order Markov chains

조회 수: 1 (최근 30일)
olig
olig 2013년 6월 13일
Any help would be much appreciated! What I am trying to do is produce a program that involves Markov chains. I have a vector B which contains a random sequence of numbers from 1 to 16 in the first column (corresponding to groups types) and then in the second column of vector B which contains a quantity in the group.
What I want to do is produce a transition matrix so it gives the probability of one state going to another. Take the simple example of:
B(10,1)= [ 1; 1; 3; 3; 2; 2; 3; 1; 2; 3]
B(10,2)= [1; 3; 5; 3; 2; 6; 7; 9 ;8; 6]
Only taking the 1st column into account:
So the transition of going from a 1=>1 is 1/10
So the transition of going from a 1=>2 is 1/10
So the transition of going from a 1=>3 is 1/10
So the transition of going from a 2=>1 is 0/10
So the transition of going from a 2=>2 is 1/10
So the transition of going from a 2=>3 is 2/10
So the transition of going from a 3=>1 is 1/10
So the transition of going from a 3=>2 is 1/10
So the transition of going from a 3=>3 is 1/10
The transition matrix would be output into a 3x3 matrix would be:
Trans=[0.1, 0.1, 0.1; 0.0, 0.2, 0.1; 0.1, 0.1, 0.1]
Any help would be great!

채택된 답변

Youssef  Khmou
Youssef Khmou 2013년 6월 13일
hi olig,
You can try to use the function "HMMESTIMATE" which a default Matlab function :
As an example, we take a sequence of numbers from 1 to 10:
seq=1:10;
The states is a matrix B with the same length as seq :
B=round(10*rand(10));
The function generates the transition and emission matrices as the following :
[Trans,Emis]=hmmestimate(seq,B)
I think this example can be adjusted to your case .

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Markov Chain Models에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by