I am trying to compute a function that calculates the equilibrium probabilities of a Markov chain. For this problem, is have already got my transition matrix.
Now I am trying to define a function called Jacobi but confused about the most effective way to do so. Any suggestions on how to do this?
So far I have tried setting it us like a system of equations and solving x=a^(-1)*b but fail to implement it correctly due to the transition matrix being singular.
I know I need to multiple the transition matrix by a variable matrix to get 7 separate equations. Then I need to add the equation x0 + x1 + x2 + x3 + x4 + x5 + x6 = 1. After I have all 8 equations I can solve for x0 through x6 to get my equilibrium probabilities. Do you know how I can implement this process in python code?
I'm not sure the Jacobi method works for a Markov transition matrix. There are other, easier techniques for finding the stationary distribution though. First by solving the system of equations like you described:
You can also repeatedly multiply
M
by itself until it converges: