Dove's LibraryDove's Library

4.14 - Matrices Modeling Contexts

Overview

Lots of situations involve things switching between two states at regular time steps: customers moving between two coffee shops each week, people moving between a city and its suburbs each year, or bikes ending the day at one station or another. A transition matrix stores the switching rates. Multiply by it to step forward in time, multiply by its inverse to step backward, and multiply over and over to see where things settle in the long run.

Building a transition matrix

Here's the setup used throughout this page. A town has two coffee shops, Brew and Bean, and 1,000 regular customers. Each week:
  • 80% of Brew's customers come back to Brew, and the other 20% switch to Bean.
  • 70% of Bean's customers come back to Bean, and the other 30% switch to Brew.
The state vector lists how many customers are in each state at one time step, written as a column. Let x⃗n\vec{x}_n be the state vector after nn weeks, with Brew on top and Bean on the bottom.
The transition matrix TT has one column for each state customers come from and one row for each state they go to. The entry in row ii, column jj is the fraction of state jj that moves to state ii in one step. Write each percent as a decimal:
From Brew
From Bean
To Brew
0.80
0.30
To Bean
0.20
0.70
T=[0.800.300.200.70]T = \begin{bmatrix} 0.80 & 0.30 \\ 0.20 & 0.70 \end{bmatrix}
Each column adds up to 1, because everyone in a state has to end up somewhere (100% of Brew's customers either stay or switch). That's the quick check that the matrix is set up the right way. The rows don't need to add up to 1.
Why set it up this way? Multiply TT by a state vector:
[0.800.300.200.70][BrewBean]=[0.80(Brew)+0.30(Bean)0.20(Brew)+0.70(Bean)]\begin{bmatrix} 0.80 & 0.30 \\ 0.20 & 0.70 \end{bmatrix}\begin{bmatrix} \text{Brew} \\ \text{Bean} \end{bmatrix} = \begin{bmatrix} 0.80(\text{Brew}) + 0.30(\text{Bean}) \\ 0.20(\text{Brew}) + 0.70(\text{Bean}) \end{bmatrix}
The top entry is next week's Brew customers: the 80% of Brew's customers who stayed plus the 30% of Bean's customers who switched in. The bottom entry does the same for Bean. The matrix multiplication does all the bookkeeping.
A transition diagram shows the same rates as arrows between the states:
4.14 - Matrices Modeling Contexts

Example 1: City and suburbs

Each year, 6% of a city's residents move to the suburbs, and 3% of suburban residents move to the city. Everyone else stays put. Write the transition matrix, with the city as the first state and the suburbs as the second.
The context gives the rates of moving. The rates of staying are what's left: 100%−6%=94%100\% - 6\% = 94\% of city residents stay, and 100%−3%=97%100\% - 3\% = 97\% of suburban residents stay. Columns are "from" and rows are "to":
From City
From Suburbs
To City
0.94
0.03
To Suburbs
0.06
0.97
T=[0.940.030.060.97]T = \begin{bmatrix} 0.94 & 0.03 \\ 0.06 & 0.97 \end{bmatrix}
Check: 0.94+0.06=10.94 + 0.06 = 1 and 0.03+0.97=10.03 + 0.97 = 1.

Predicting future states

Multiplying the transition matrix by the current state vector gives the state one step later:
x⃗n+1=Tx⃗n\vec{x}_{n+1} = T\vec{x}_n
To go two steps ahead, multiply by TT twice: x⃗2=T(Tx⃗0)=T2x⃗0\vec{x}_2 = T(T\vec{x}_0) = T^2\vec{x}_0. In general,
x⃗n=Tnx⃗0\vec{x}_n = T^n\vec{x}_0
On a TI-84, store TT as [A] and the starting state vector as [B] (a 2×12 \times 1 matrix), then compute [A]^n*[B] with your value of nn. Here TnT^n means multiplying the matrix by itself nn times, not raising each entry to the nnth power.

Example 2: Two weeks ahead

This week (week 0), Brew and Bean each have 500 customers. Predict the number of customers at each shop next week and two weeks from now.
Next week:
x⃗1=Tx⃗0=[0.800.300.200.70][500500]=[400+150100+350]=[550450]\vec{x}_1 = T\vec{x}_0 = \begin{bmatrix} 0.80 & 0.30 \\ 0.20 & 0.70 \end{bmatrix}\begin{bmatrix} 500 \\ 500 \end{bmatrix} = \begin{bmatrix} 400 + 150 \\ 100 + 350 \end{bmatrix} = \begin{bmatrix} 550 \\ 450 \end{bmatrix}
Two weeks from now:
x⃗2=Tx⃗1=[0.800.300.200.70][550450]=[440+135110+315]=[575425]\vec{x}_2 = T\vec{x}_1 = \begin{bmatrix} 0.80 & 0.30 \\ 0.20 & 0.70 \end{bmatrix}\begin{bmatrix} 550 \\ 450 \end{bmatrix} = \begin{bmatrix} 440 + 135 \\ 110 + 315 \end{bmatrix} = \begin{bmatrix} 575 \\ 425 \end{bmatrix}
You get the same result from T2x⃗0T^2\vec{x}_0 in one step:
T2=[0.700.450.300.55],T2[500500]=[350+225150+275]=[575425]T^2 = \begin{bmatrix} 0.70 & 0.45 \\ 0.30 & 0.55 \end{bmatrix}, \qquad T^2\begin{bmatrix} 500 \\ 500 \end{bmatrix} = \begin{bmatrix} 350 + 225 \\ 150 + 275 \end{bmatrix} = \begin{bmatrix} 575 \\ 425 \end{bmatrix}
Answer: the model predicts 550 Brew customers and 450 Bean customers next week, and 575 Brew customers and 425 Bean customers in two weeks. The total stays at 1,000, as it should, since customers only move between the two shops.

The steady state

Keep multiplying by TT week after week and watch the numbers. (The model can give fractions of a customer. Think of them as averages, and round only when you report an answer.)
Week nn
0
1
2
3
4
5
Brew
500
550
575
587.5
593.75
596.875
Bean
500
450
425
412.5
406.25
403.125
Brew's count keeps climbing toward 600 and Bean's keeps falling toward 400, and each week the gap is cut in half.
4.14 - Matrices Modeling Contexts
That leveling off is the steady state: a distribution between the states that doesn't change from one step to the next. In symbols, a steady state s⃗\vec{s} satisfies
Ts⃗=s⃗T\vec{s} = \vec{s}
Check it here:
[0.800.300.200.70][600400]=[480+120120+280]=[600400]\begin{bmatrix} 0.80 & 0.30 \\ 0.20 & 0.70 \end{bmatrix}\begin{bmatrix} 600 \\ 400 \end{bmatrix} = \begin{bmatrix} 480 + 120 \\ 120 + 280 \end{bmatrix} = \begin{bmatrix} 600 \\ 400 \end{bmatrix}
Customers haven't stopped switching. Each week, 20% of 600, or 120 customers, leave Brew for Bean, and 30% of 400, also 120 customers, leave Bean for Brew. The two flows cancel out, so the totals stay put.
There are two ways to find a steady state:
  • Repeated multiplication (technology): compute Tnx⃗0T^n\vec{x}_0 for a large nn. Here T20x⃗0≈[600400]T^{20}\vec{x}_0 \approx \begin{bmatrix} 600 \\ 400 \end{bmatrix}, and larger values of nn give the same thing.
  • Algebra: call the steady state [ab]\begin{bmatrix} a \\ b \end{bmatrix}. The top row of Ts⃗=s⃗T\vec{s} = \vec{s} says 0.80a+0.30b=a0.80a + 0.30b = a, which simplifies to 0.30b=0.20a0.30b = 0.20a, or b=23ab = \frac{2}{3}a. The total is fixed at 1,000, so a+23a=1000a + \frac{2}{3}a = 1000, which gives a=600a = 600 and b=400b = 400.
For transition matrices like this one, where every entry is positive, the steady state doesn't depend on where you start. Even if all 1,000 customers started at Brew, the model would still head to 600 and 400. Only the total matters, which is why a steady state is often given as percents: in the long run, about 60% of the customers go to Brew and 40% go to Bean.

Predicting past states

Since x⃗n+1=Tx⃗n\vec{x}_{n+1} = T\vec{x}_n, you can go backward by undoing the multiplication with the inverse matrix from Topic 4.11:
x⃗n=T−1x⃗n+1\vec{x}_n = T^{-1}\vec{x}_{n+1}
Each multiplication by T−1T^{-1} steps one time period into the past. To go back kk steps, multiply by T−1T^{-1} a total of kk times.

Example 3: Going back in time

Brew and Bean each have 500 customers this week. How many customers did each shop have last week? Two weeks ago?
Step 1: Find T−1T^{-1}. The determinant is det⁡(T)=(0.80)(0.70)−(0.30)(0.20)=0.56−0.06=0.5\det(T) = (0.80)(0.70) - (0.30)(0.20) = 0.56 - 0.06 = 0.5, so
T−1=10.5[0.70−0.30−0.200.80]=[1.4−0.6−0.41.6]T^{-1} = \frac{1}{0.5}\begin{bmatrix} 0.70 & -0.30 \\ -0.20 & 0.80 \end{bmatrix} = \begin{bmatrix} 1.4 & -0.6 \\ -0.4 & 1.6 \end{bmatrix}
Step 2: Multiply this week's state by T−1T^{-1} to get last week's.
T−1[500500]=[700−300−200+800]=[400600]T^{-1}\begin{bmatrix} 500 \\ 500 \end{bmatrix} = \begin{bmatrix} 700 - 300 \\ -200 + 800 \end{bmatrix} = \begin{bmatrix} 400 \\ 600 \end{bmatrix}
Step 3: Do it again to get two weeks ago.
T−1[400600]=[560−360−160+960]=[200800]T^{-1}\begin{bmatrix} 400 \\ 600 \end{bmatrix} = \begin{bmatrix} 560 - 360 \\ -160 + 960 \end{bmatrix} = \begin{bmatrix} 200 \\ 800 \end{bmatrix}
Check by going forward one week from last week's numbers:
T[400600]=[320+18080+420]=[500500]T\begin{bmatrix} 400 \\ 600 \end{bmatrix} = \begin{bmatrix} 320 + 180 \\ 80 + 420 \end{bmatrix} = \begin{bmatrix} 500 \\ 500 \end{bmatrix}
Answer: last week, Brew had 400 customers and Bean had 600. Two weeks ago, Brew had 200 and Bean had 800.
Notice that T−1T^{-1} has negative entries, so it isn't a transition matrix itself. It's only a tool for undoing one. That also means going back too far can give impossible answers. One more step back gives T−1[200800]=[−2001200]T^{-1}\begin{bmatrix} 200 \\ 800 \end{bmatrix} = \begin{bmatrix} -200 \\ 1200 \end{bmatrix}, a negative number of customers. The model can't explain this week's numbers that far back, so the backward predictions stop making sense after two weeks. Always check that a past state is realistic.

Example 4: Bike-share stations

A bike-share program has 200 bikes and two stations, North and South. Each day, 70% of the bikes that start at North end the day at North, and the rest end at South. Of the bikes that start at South, 20% end the day at North and the rest end at South. This morning, 140 bikes are at North and 60 are at South.
  • (a) Write the transition matrix TT, with North as the first state.
  • (b) Predict the number of bikes at each station after one day and after two days.
  • (c) How many bikes were at each station one day earlier?
  • (d) Find the steady state and explain what it means for the program.
(a) The rates of staying are 70% at North and 100%−20%=80%100\% - 20\% = 80\% at South:
T=[0.700.200.300.80]T = \begin{bmatrix} 0.70 & 0.20 \\ 0.30 & 0.80 \end{bmatrix}
Both columns add up to 1.
(b) Multiply once, then again:
T[14060]=[98+1242+48]=[11090]T[11090]=[77+1833+72]=[95105]T\begin{bmatrix} 140 \\ 60 \end{bmatrix} = \begin{bmatrix} 98 + 12 \\ 42 + 48 \end{bmatrix} = \begin{bmatrix} 110 \\ 90 \end{bmatrix} \qquad T\begin{bmatrix} 110 \\ 90 \end{bmatrix} = \begin{bmatrix} 77 + 18 \\ 33 + 72 \end{bmatrix} = \begin{bmatrix} 95 \\ 105 \end{bmatrix}
After one day, the model predicts 110 bikes at North and 90 at South. After two days, it predicts 95 at North and 105 at South.
(c) det⁡(T)=(0.70)(0.80)−(0.20)(0.30)=0.5\det(T) = (0.70)(0.80) - (0.20)(0.30) = 0.5, so
T−1=10.5[0.80−0.20−0.300.70]=[1.6−0.4−0.61.4]T^{-1} = \frac{1}{0.5}\begin{bmatrix} 0.80 & -0.20 \\ -0.30 & 0.70 \end{bmatrix} = \begin{bmatrix} 1.6 & -0.4 \\ -0.6 & 1.4 \end{bmatrix}T−1[14060]=[224−24−84+84]=[2000]T^{-1}\begin{bmatrix} 140 \\ 60 \end{bmatrix} = \begin{bmatrix} 224 - 24 \\ -84 + 84 \end{bmatrix} = \begin{bmatrix} 200 \\ 0 \end{bmatrix}
One day earlier, all 200 bikes were at North and none were at South. Check: T[2000]=[14060]T\begin{bmatrix} 200 \\ 0 \end{bmatrix} = \begin{bmatrix} 140 \\ 60 \end{bmatrix}.
(d) Call the steady state [NS]\begin{bmatrix} N \\ S \end{bmatrix}, with N+S=200N + S = 200. The top row of Ts⃗=s⃗T\vec{s} = \vec{s} gives 0.70N+0.20S=N0.70N + 0.20S = N, so 0.20S=0.30N0.20S = 0.30N, or S=1.5NS = 1.5N. Then N+1.5N=200N + 1.5N = 200, so N=80N = 80 and S=120S = 120.
Check: T[80120]=[56+2424+96]=[80120]\text{Check: } T\begin{bmatrix} 80 \\ 120 \end{bmatrix} = \begin{bmatrix} 56 + 24 \\ 24 + 96 \end{bmatrix} = \begin{bmatrix} 80 \\ 120 \end{bmatrix}
In the long run, the model predicts about 80 bikes at North and 120 at South each day, so the program should plan for South to need more docking space than North.

Common mistakes

  • Putting "from" in the rows. Columns are "from" and rows are "to." If your columns don't each add up to 1, the matrix is flipped.
  • Using percents as whole numbers. 80% goes into the matrix as 0.80, not 80.
  • Multiplying in the wrong order. The next state is Tx⃗T\vec{x}, with the matrix on the left.
  • Using TT to go backward. Past states need T−1T^{-1}. Future states use TT.
  • Raising each entry to a power. T3T^3 means T⋅T⋅TT \cdot T \cdot T with matrix multiplication, not cubing each entry.
  • Rounding too early. Keep full decimals in each state vector and round only the final answer.
  • Thinking the steady state means nobody switches. People still move. The numbers moving each way just balance out.
  • Not checking past states. A negative number in a past state means the model doesn't reach back that far.
Next

AP® is a registered trademark of the College Board, which is not affiliated with Dove's Library and was not involved in the production of, and does not endorse, this website.

Providing free, high-quality AP notes to help students succeed, earn college credit, and reach their educational goals, ensuring everyone has access to the resources they need.

© 2026 Standard Learning Group, Inc., which operates Dove's Library. All rights reserved.