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 be the state vector after weeks, with Brew on top and Bean on the bottom.
The transition matrix has one column for each state customers come from and one row for each state they go to. The entry in row , column is the fraction of state that moves to state 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 |
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 by a state vector:
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:

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: of city residents stay, and 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 |
Check: and .
Predicting future states
Multiplying the transition matrix by the current state vector gives the state one step later:
To go two steps ahead, multiply by twice: . In general,
On a TI-84, store as
[A] and the starting state vector as [B] (a matrix), then compute [A]^n*[B] with your value of . Here means multiplying the matrix by itself times, not raising each entry to the th 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:
Two weeks from now:
You get the same result from in one step:
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 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 | 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.

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 satisfies
Check it here:
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 for a large . Here , and larger values of give the same thing.
- Algebra: call the steady state . The top row of says , which simplifies to , or . The total is fixed at 1,000, so , which gives and .
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 , you can go backward by undoing the multiplication with the inverse matrix from Topic 4.11:
Each multiplication by steps one time period into the past. To go back steps, multiply by a total of 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 . The determinant is , so
Step 2: Multiply this week's state by to get last week's.
Step 3: Do it again to get two weeks ago.
Check by going forward one week from last week's numbers:
Answer: last week, Brew had 400 customers and Bean had 600. Two weeks ago, Brew had 200 and Bean had 800.
Notice that 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 , 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 , 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 at South:
Both columns add up to 1.
(b) Multiply once, then again:
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) , so
One day earlier, all 200 bikes were at North and none were at South. Check: .
(d) Call the steady state , with . The top row of gives , so , or . Then , so and .
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 , with the matrix on the left.
- Using to go backward. Past states need . Future states use .
- Raising each entry to a power. means 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.
BackNext