Absorbing Markov Chains - Anyone have experience in calculating probability ?

Nerevarine

Incarnate
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 !
 
Last edited:

quicky008

Technomancer
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)
 
OP
Nerevarine

Nerevarine

Incarnate
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

In the zone
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
 
OP
Nerevarine

Nerevarine

Incarnate
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.
 
OP
Nerevarine

Nerevarine

Incarnate
*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
 
Top Bottom