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!