Markov Chains Explained
Introduction to Markov Chains
What Happens Next?
Many systems in the world change over time. The weather shifts from sunny to rainy. A stock price goes up or down. A customer is either active or has churned. We can think of each of these possibilities as a state. A Markov chain is a mathematical model that describes how a system moves between these states.
Imagine a very simple weather model. There are only two possible states: Sunny or Rainy. If today is Sunny, what will it be tomorrow? It could be Sunny again, or it could turn Rainy. A Markov chain helps us put probabilities on those future outcomes.
Each arrow in the diagram represents a state transition. The number on each arrow is the transition probability, which is the chance of moving from one state to another. For example, if it's Sunny today, there might be an 80% chance it will be Sunny tomorrow and a 20% chance it will be Rainy. Notice that the probabilities for all arrows leaving a single state must add up to 100% (or 1.0), because something must happen next.
The Memoryless Property
The most important rule for Markov chains is the Markov property. It states that the probability of the next state depends only on the current state. It doesn't depend on any of the states that came before.
In a Markov chain, the future is independent of the past, given the present.
In our weather example, if we want to predict tomorrow's weather, all we need to know is whether today is Sunny or Rainy. It doesn't matter if it was sunny for the last ten days or if there was a week of rain before today. The past is forgotten; only the present matters for predicting the next step. This is why the Markov property is often called the "memoryless" property.
state
noun
A specific condition or situation a system can be in at a particular time.
This assumption simplifies modeling complex systems tremendously. While not perfectly true for all real-world scenarios (today's weather is, in fact, influenced by more than just yesterday's), it's a powerful and useful approximation for countless applications, from predicting customer behavior to modeling molecular dynamics.
Transition Probabilities
The engine of a Markov chain is its set of transition probabilities. We can organize these probabilities into a grid, or matrix, to see them all at once. For our weather model, the transition matrix would look like this:
| From | To Sunny | To Rainy |
|---|---|---|
| Sunny | 0.8 | 0.2 |
| Rainy | 0.4 | 0.6 |
This table tells us the same story as the diagram. If the current state is Sunny (the first row), there's a 0.8 probability of transitioning to Sunny and a 0.2 probability of transitioning to Rainy. Each row in the matrix represents a starting state, and the values in that row must sum to 1.
transition
noun
A change from one state to another in a system.
By defining the states and the transition probabilities, we create a complete Markov chain. This simple framework allows us to ask powerful questions about the future behavior of a system, like "What is the probability it will be sunny three days from now?" or "In the long run, what percentage of days are rainy?"
The defining feature of a Markov chain is the Markov property, which is often described as the system being "memoryless". What does this mean?
A transition matrix organizes the probabilities of moving between states. What is a fundamental rule for any valid transition matrix?