Search code examples
matlabmatrixmarkov-chainsmarkov-models

How to solve Markov transition rate matrix?


I have some variables to find like x= [1x16 (x1,x2,x3,....x16 variables)] with condition that x1+x2+x3+....x16=1. I have also 16x16 matrix Q= [16x16 (real values)].

I need to solve the equation 'x*Q=x' as shown here. How can I solve it in Matlab or in any other language easily?


Solution

  • By transposition, your equation is equivalent to Q'y=1y where y:=x' (a column vector) where Q' is the transpose of Q (matlab notation...) which means that y is an eigenvector associated with eigenvalue 1 for matrix Q'. Such an eigenvector always exists for a Markov matrix. Let s be the sum of the entries of column vector y. Two cases can occur :

    • either s is not 0 ; then it suffices to divide all coordinates of y by s : we obtain a vector that is still an eigenvector, with a coordinate sum equal to 1.

    • or s=0 and there is no solution to your problem.

    Here is a Matlab program that does the work for a 3 x 3 matrix :

    M=[.2 .3 .5
       .1 .8 .1
       .4 .4 .2]
    [P,D]=eig(M')
    Y=P(:,3)
    M'*Y - Y,% should be 0
    Z=Y/sum(Y),%the sum of Z's coordinates is 1
    M'*Z-Z,% should be 0