First order Markov chains
1 view (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Youssef Khmou
on 13 Jun 2013
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 Comments
More Answers (0)
See Also
Categories
Find more on Markov Chain Models in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!