The Long Run
← Back to blog

Data Science

The Fundamental Matrix (F): Exact Absorption Probabilities and Removal Effects

Part 4 (optional, technical): a recap of Parts 1 to 3, then the matrix steps F = (I − Q)⁻¹ and FR that give exact absorption probabilities and removal effects.

·10 min read

📌 This part is optional. It is the technical companion to Parts 1 to 3 and shows the matrix maths behind their numbers. Nothing later in the series depends on it: if the route calculations in Part 3 made sense, you can skip straight to Part 5.

Covered so far
  • Part 1: a simulation of 10,000 cars, which gives approximate counts
  • Part 2: the TPM, multiplied step after step to approach the 49.5% airport share
  • Part 3: removal effects by listing routes, with looping routes estimated
In this part
  • The textbook terms for absorbing chains, and the TPM in canonical form
  • Splitting the TPM into four blocks: Q, R, O and I
  • The fundamental matrix F and the probability of absorption FR
  • Exact removal effects by closing a junction and recomputing

Every number in this series so far has been either approximate or worked out by hand. This part shows how the same numbers come out of a few matrix operations, step by step, with the actual values at each step so you can follow along on paper.

Where we are in the series

Each earlier part answered one question and left a small gap behind.

PartWhat it coveredWhat it gave usWhat it left open
1. What is a Markov chain?States, transitions, the Markov property (only the current state matters), and the Sampur road networkA simulation of 10,000 cars: 4,878 reached the airport, and 1,069 did when the flyover was closedA random run wobbles from one run to the next, so the counts are approximate
2. The TPMBuilding the Transition Probability Matrix from a sample trip log of 2,000 trips, then multiplying it by itself to follow traffic forwardThe airport share settling near 49.5% after about six movesRepeated multiplication gets closer and closer to the answer but never reaches it exactly
3. Chain order and the removal effectFirst- vs second-order chains, and the removal effect worked out by listing routesRemoval effects of 64.4% (Market Square), 51.5% (Ring Road) and 78.5% (Flyover)Routes that loop between Market Square and Ring Road had to be estimated

Table 1: What Parts 1 to 3 covered, and the gap each one left.

Part 4 closes all three gaps at once. The matrix method gives the exact airport share without simulation, adds up every possible number of moves without stopping early, and counts the looping routes automatically.

What this part explains

In textbooks, this topic is called the theory of absorbing Markov chains. The terms below appear in any course or paper on the subject, so each one is listed with its plain meaning and its Sampur example.

Academic termPlain meaningIn Sampur
Transient stateA state the chain passes through and eventually leaves for goodCity entry, Market Square, Ring Road, Flyover
Absorbing stateA state that ends the journey: once reached, the chain stays thereAirport, Left city
Absorbing Markov chainA chain where every transient state can eventually reach an absorbing stateEvery car's trip ends at the Airport or by leaving the city
Canonical formThe TPM reordered so transient states come first and absorbing states lastJunctions first, then Airport and Left city
Q, R, O, IThe four blocks of the canonical formQ: junction to junction; R: junction to end of trip
Matrix inverse, ⁻¹The matrix version of "1 divided by a number"Used once, to turn I − Q into F
Fundamental matrix, FExpected number of visits to each transient state before absorptionA car entering the city uses the Flyover 0.49 times on average
Probability of absorption, FRProbability that a journey starting in each transient state ends in each absorbing state49.47% of cars entering the city reach the Airport
Removal effectShare of successful journeys lost when one state is removedClosing the Flyover loses 78.5% of airport arrivals

Table 2: The technical terms in this part, in plain words and in Sampur.

The whole calculation is six steps, shown in Figure 1. Each step has its own section below.

Figure 1: The matrix calculation in this part, from the TPM to the exact removal effect.

Steps 1 and 2 only rearrange numbers we already have. Step 3 prepares the matrix for Step 4, which is the one real piece of new maths. Steps 5 and 6 are multiplication and a rerun.

This part uses the Part 1 values, the probabilities the sample data was created from, so every result can be compared with the earlier parts.

Step 1: the TPM, P

We start from Sampur's TPM from Parts 1 and 2. Each row is where a car is now, each column is where it goes next, and each row adds up to 1. The two absorbing states each get a row too: a car at the Airport stays at the Airport with probability 1, and the same goes for Left city.

Step 2: split the TPM into four blocks

Any absorbing Markov chain can be written in canonical form: list the transient states first and the absorbing states last. The TPM then splits into four blocks:

P = | Q  R |
    | O  I |

Figure 2: Sampur's TPM in canonical form, with transient states first and absorbing states last.

  • Q (blue, 4 × 4) is the transient block. It holds the probabilities of moving from one transient state to another, junction to junction.
  • R (amber, 4 × 2) is the absorption block. It holds the probabilities of absorption in a single step: moving from a junction straight to the Airport or out of the city.
  • O (grey, 2 × 4) is the null block. Every entry is 0, because a finished trip never returns to a junction.
  • I (green, 2 × 2) is the identity block: 1s on the diagonal and 0s elsewhere, so each absorbing state stays where it is.

O and I look the same in every absorbing chain, so all the useful information sits in Q and R. Here they are with their numbers:

Q: from ↓ to →City entryMarket SquareRing RoadFlyover
City entry00.60.40
Market Square000.20.5
Ring Road00.100.3
Flyover0000

Table 3: Q, the probabilities of moving from one junction to another.

R: from ↓ to →AirportLeft city
City entry00
Market Square00.3
Ring Road0.20.4
Flyover0.80.2

Table 4: R, the probabilities of a trip ending in one move.

Each junction's row in Q and its row in R together add up to 1. Ring Road, for example, gives 0.1 + 0.3 in Q and 0.2 + 0.4 in R, a total of 1.0. Every car at a junction either moves to another junction or ends its trip.

Step 3: work out I − Q

The next step subtracts Q from an identity matrix I of the same size: a 4 × 4 matrix with 1s on the diagonal and 0s everywhere else. Subtracting matrices works cell by cell.

I − QCity entryMarket SquareRing RoadFlyover
City entry1−0.6−0.40
Market Square01−0.2−0.5
Ring Road0−0.11−0.3
Flyover0001

Table 5: I − Q, the identity matrix minus the junction-to-junction moves.

The table itself has no traffic meaning. It is the matrix version of the expression 1 − x, and it exists to be inverted in the next step.

Step 4: invert to get the fundamental matrix F

The fundamental matrix is defined as:

F = (I − Q)⁻¹

The superscript ⁻¹ means the matrix inverse. For an ordinary number, the inverse of 4 is 1 ÷ 4. For a matrix, the inverse plays the same role. In practice a computer works it out in one line of code (the script is linked below), so the useful part to understand is what the result means.

Why an inverse counts visits

Start with a small case from Sampur. A car at Market Square can go to Ring Road (probability 0.2) and then come back to Market Square (probability 0.1). One loop therefore happens with probability 0.2 × 0.1 = 0.02. The expected number of times the car is at Market Square is:

  • 1 for the visit it is on now
  • plus 0.02 for one loop back
  • plus 0.02 × 0.02 for two loops, and so on

1 + 0.02 + 0.02² + … = 1 ÷ (1 − 0.02) = 1.02

That is the standard result for a geometric series: 1 + x + x² + … equals 1 ÷ (1 − x) when x is between 0 and 1. The matrix version works the same way. Q gives the chances of reaching each junction in one move, Q² in exactly two moves, Q³ in three, and so on. Adding all of them, I + Q + Q² + Q³ + …, gives the expected number of visits, and that sum equals (I − Q)⁻¹. It is the "1 ÷ (1 − x)" for the whole network at once. The sum stops growing because cars keep leaving the network at every step.

The fundamental matrix for Sampur

F: start ↓, visits to →City entryMarket SquareRing RoadFlyoverRow total (expected moves)
City entry10.6530.5310.4862.67
Market Square01.0200.2040.5711.80
Ring Road00.1021.0200.3571.48
Flyover00011.00

Table 6: The fundamental matrix F, the expected number of visits to each junction.

Each entry answers one question: starting from the row's junction, how many times on average does a car visit the column's junction before its trip ends? The 1.02 for Market Square to Market Square is the loop calculation above.

Reading the City entry row:

  • Market Square, 0.653. 0.6 of a visit comes from the direct road, and 0.4 × 0.1 = 0.04 from cars that reach it through Ring Road, giving 0.64. The Market Square ↔ Ring Road loop scales that up: 0.64 ÷ 0.98 = 0.653.
  • Ring Road, 0.531. A car visits Ring Road 0.531 times on average.
  • Flyover, 0.486. No road returns to the flyover, so a car uses it at most once, and 0.486 is also the probability that a trip includes the flyover at all.

Adding a row gives the expected number of junctions a car passes through, which is the number of moves before its trip ends. From City entry the total is 2.67, which agrees closely with the 2.66 moves per trip in Part 2's sample log (5,329 moves across 2,000 trips).

Figure 3: The fundamental matrix F (left) and the probability of absorption FR (right) for Sampur.

The left panel of Figure 3 shows Table 6 as a heatmap: rows are starting points, columns are junctions and darker cells mean more visits. The right panel shows the result of the next step.

Step 5: multiply to get FR, the probability of absorption

Multiplying F by R gives the probability of absorption:

FR = F × R

The logic is a sum over junctions. A car ends at the Airport by being at some junction and then jumping to the Airport. F gives the expected visits to each junction, and R gives the chance of jumping to the Airport from there. Multiplying visits by jump chance for each junction, then adding, gives the chance of ending at the Airport. That "multiply along the row, down the column, then add" is exactly how matrix multiplication works.

Here is the City entry row worked out in full:

JunctionVisits (F, City entry row)× Jump to Airport (R)=× Jump to Left city (R)=
City entry10000
Market Square0.653000.30.196
Ring Road0.5310.20.1060.40.212
Flyover0.4860.80.3890.20.097
Total0.4950.505

Table 7: How the first row of FR is calculated, junction by junction.

So a car entering Sampur reaches the Airport with probability 49.5% (49.47% unrounded) and leaves the city with probability 50.5%. The two add up to 1, because every trip ends somewhere. Doing the same for every row gives the full FR matrix:

Starting atEnds at the AirportLeaves the city
City entry49.47%50.53%
Market Square49.80%50.20%
Ring Road48.98%51.02%
Flyover80.00%20.00%

Table 8: FR, the probability of absorption from each starting point.

What FR tells us:

  • The overall answer. 49.47% is the exact value that repeated multiplication approached in Part 2, and the Part 1 simulation (4,878 of 10,000 cars, or 48.8%) landed within normal random variation of it.
  • How promising each position is. A car that has reached the Flyover is 80% likely to arrive, compared with about 49% for a car at Market Square or Ring Road. In marketing terms, each row is the probability of converting from that point in a journey.
🔍 Deep dive: why the infinite sum equals (I − Q)⁻¹

Let S = I + Q + Q² + Q³ + …. Multiplying both sides by Q shifts every term one place: QS = Q + Q² + Q³ + …. Subtracting the second line from the first leaves S − QS = I, so (I − Q)S = I and therefore S = (I − Q)⁻¹ = F.

The argument requires the powers of Q to shrink towards zero, which happens whenever every transient state can eventually reach an absorbing state. Absorption probabilities follow the same logic: the chance of ending in absorbing state k sums, over every junction j, the expected visits to j multiplied by the probability of jumping from j to k. In matrix form that is F × R.

Step 6: close a junction and recompute

Closing a junction means any car arriving there leaves the city. In matrix terms, two rows change:

  • the junction's row in Q becomes all zeros, because no car moves on to another junction
  • its row in R becomes 0 for the Airport and 1 for Left city, because every car that arrives leaves

Everything else stays the same, and Steps 3 to 5 are run again on the changed Q and R.

Worked example: close the Flyover. The Flyover's row in Q was already all zeros, since no road leads from the flyover to another junction. Only its row in R changes, from 0.8 / 0.2 to 0 / 1. F therefore stays exactly as in Table 6, and only the last line of Table 7 changes:

JunctionVisits (F, City entry row)× Jump to Airport (new R)=
Market Square0.65300
Ring Road0.5310.20.106
Flyover (closed)0.48600
Total0.106

Table 9: The airport probability from City entry with the Flyover closed.

With the flyover closed, 10.61% of cars reach the airport, down from 49.47%:

Removal effect = 1 − (10.61 ÷ 49.47) ≈ 1 − 0.2145 ≈ 0.785, or 78.5%

Closing Market Square or Ring Road changes Q as well, so F has to be recomputed for each closure, giving the results in Table 10.

Junction closedReach the airport (FR, from City entry)Removal effectPart 3 hand calculation
None49.47%Baseline49.47%
Market Square17.60%64.4%17.60%, exact
Ring Road24.00%51.5%24.00%, exact
Flyover10.61%78.5%10.40% from the six routes, plus about 0.21% from loops

Table 10: Exact removal effects from the matrix method, compared with the hand calculation in Part 3.

The matrix confirms Part 3. The route calculation was already exact for Market Square and Ring Road, because closing either one removes every looping route. For the Flyover, F counts the looping cars without any extra step: the 0.531 visits to Ring Road in Table 9 already include them.

⚠️ Pitfall: The inverse of (I − Q) exists only if every transient state can eventually reach an absorbing state. In real journey data, a coding error such as a channel that only ever transitions to itself makes the matrix impossible to invert. Check the absorbing rows before computing F.

What the matrices mean for attribution

Each quantity in this part has a direct marketing counterpart:

  • F becomes the expected number of times each channel appears in a journey.
  • FR becomes the probability of conversion from any point in a journey.
  • Recomputing FR with a channel removed gives that channel's exact removal effect, which Part 3 then scales into a share of credit.

Attribution tools run these same calculations behind the scenes. Part 5 applies them to marketing journeys.

Key Takeaways

  • Parts 1 to 3 gave approximate or hand-built answers. The theory of absorbing Markov chains gives the exact ones from the TPM alone.
  • In canonical form, the TPM splits into Q (junction to junction), R (junction to end of trip), O (a null block of zeros) and I (identity).
  • The fundamental matrix F = (I − Q)⁻¹ is the sum I + Q + Q² + …, the matrix version of 1 ÷ (1 − x). Each entry is an expected number of visits, and each row total is the expected number of moves: 2.67 from City entry.
  • FR = F × R is the probability of absorption. It multiplies visits by jump chances and adds them up: 49.47% of cars entering Sampur reach the airport.
  • Closing a junction changes its rows in Q and R. Recomputing FR gives the exact removal effect: 78.5% for the Flyover, 64.4% for Market Square and 51.5% for Ring Road.

➡️ Up next: Part 5: Markov Chain Attribution swaps junctions for marketing channels. It covers Kesari Threads' customer journeys, conversion and null paths, and each channel's removal effect and share of credit.

Quick Quiz: Test Yourself

🧠 Test yourself: 6 questions (click to open)

1. In canonical form, what does the block R contain?

2. What does the O block contain, and why?

3. A car at Market Square loops through Ring Road and back with probability 0.02. Why is the Market Square to Market Square entry of F equal to 1.02?

4. An entry of the fundamental matrix F in row "City entry" and column "Ring Road" equals 0.53. What does it mean?

5. How is the probability of absorption calculated?

6. How is a junction "closed" when computing its exact removal effect?

0 of 6 answered

Unsure about a term? See the Markov Chain Attribution Jargon Checklist.

In case of any queries or feedback, feel free to drop a comment or reach out using the Contact section.

Comments