DIGIT-ARC read-only archive · snapshot: July 23, 2026

Absorbing Markov Chains - Anyone have experience in calculating probability ?

8 posts · originally from https://geek.digit.in/community/threads/absorbing-markov-chains-anyone-have-experience-in-calculating-probability.209696/

Nerevarine
Nerevarine Original post #1
May 27, 2021 at 4:18 PM
Hi, I am writing a program to calculate the probability of state transition from a specific transient state to all absorbing states.
Does anyone have experience in absorbing markov chains, i have couple of queries to ask.

main question is how to scale a matrix to nxn.. If anyone can provide a detailed walkthrough on how to solve one, id be grateful. Examples online are too detailed and im having difficulty grasping it. I know matrix operations and linear algebra but this is out of my field of work.


This guy worked on a 4x4 matrix with 2 transition states and 2 absorbing states. Im having difficulty scaling this up. If I scale it up to say 6, with 2 transition and 4 absorbing states, Im having a problem where we have to substract 2 matrices of different dimensions to calculate F. Thats not possible !
quicky008
May 27, 2021 at 6:03 PM
I wish i could help you but this is way out of my area of expertise (just a figure of speech-out of area of expertise implies that i am an expert in the first place in some field,which unfortunately i am not-for all intents and purposes,i am nothing but a noob)
khalil1210
May 27, 2021 at 11:33 PM
Here the person says I is same size as Q, I guess in your case 1st Matrix will be identity matrix of 2x2

Nerevarine
May 28, 2021 at 1:21 AM
Yes you are absolutely right, the identity matrix that I choose has to be the same size as the Q matrix. I have managed to solve that part. Now Im stuck in a different issue.

My matrix is entirely filled with fractions (probability). If I invert a fractional matrix using either gaussian elimination or determinant, i get the value in decimals (double or float).


Any idea how to convert to nearest fraction again, (My solution requires me to output in fractions with denom and numerator separately). Alternately, is there anyway to do matrix inversion keeping fractional values.

I tried Algorithm for simplifying decimal to fractions with varying precision but the numbers i m getting are like 25165803/117440414 instead of 3/14

The solution doesnt get accepted. The problem im doing has general accepted solution all over the web but Im trying to avoid and implement from scratch. Most of the solutions use numpy to do all this calculations in python, im doing in java.
khalil1210
May 28, 2021 at 2:10 AM
Can you share the sample matrix which you are trying to invert, May be I will get idea.

May be convert the F matrix to fractions and preserve the fraction and try to invert using determinant method

like instead of using
Code:
Array  0.2 0.8
       1   0
     
Make it as  1/5  2/5
            1    0


May be this will help,

*stackoverflow.com/questions/474535/best-way-to-represent-a-fraction-in-java
Nerevarine
May 28, 2021 at 2:28 AM
Matrix :
1 -2/3
0 1

trying to invert this. So far trying Adjoint and Inverse of a Matrix - GeeksforGeeks to invert the matrix.
However, in the above link, there is hardcoded N = 4.
Nerevarine
May 28, 2021 at 8:11 AM
I've managed to solve it but it's failing 2 test cases. I'll post here tonight. Gnight or gmorning whoever is reading this
Nerevarine
May 29, 2021 at 9:35 PM
*github.com/Sunil-P/Google-Foobar

Solution along with question here. I am not a java guy, so forgive the bad standards. The challenge only allowed python or java.

*github.com/Sunil-P/Google-Foobar/tree/main/src/doomsdayfuel