Welcome back. In our previous lesson, we established the conceptual landscape of our study, distinguishing between Markov chains, reward processes, and decision processes. We saw that the Markov Decision Process (MDP) is our ultimate object of study, providing a complete framework for an agent making choices in a stochastic environment.
Today, we will move from that high-level overview to a rigorous, formal definition. Our goal is to specify exactly what mathematical objects are required to define a finite MDP. Think of this as drafting a precise blueprint for a decision-making problem. This formal specification is not just a theoretical exercise; it is the essential foundation you will need to implement and solve MDPs, which we will begin doing in the next module.
The Anatomy of a Finite MDP
A Markov Decision Process, in its most common form, is defined by a collection of mathematical components. A concise reading from a set of Stanford lecture notes provides an excellent formal definition of this structure.
This document by Garrett Thomas offers a clear and formal definition of an MDP as a tuple. It systematically lists and explains each component, which aligns perfectly with our objective for this lesson.
Please read the section "2 Markov Decision Processes," starting from the beginning of the page. Focus on the list of components that define an MDP. Pay close attention to the mathematical notation used for each part, such as T : S × A →∆(S), and make sure you understand the definitions of a finite MDP and a tabular MDP. (Note: The resource uses T for transitions and r for rewards; we will often use P and R respectively, but the concepts are identical).
As you saw in the reading, specifying an MDP requires us to define each of its parts. Let's examine them one by one, adding some important details and interpretations. For the remainder of this course, unless stated otherwise, we will focus on finite, stationary, infinite-horizon, discounted MDPs. This means the state and action sets are finite, the rules don't change over time, and we plan over a potentially infinite future using a discount factor.
1. State and Action Spaces ( and )
- The State Space : This is the set of all possible situations the agent can be in. A state must be Markov, meaning it summarizes all relevant information from the past. For a finite MDP, is a finite set, such as .
- The Action Space : This is the set of all possible decisions the agent can make. For a finite MDP, is also a finite set, like . In many problems, the set of available actions may depend on the state, which we can denote as .
2. The Transition Kernel ()
The transition kernel, or transition model, dictates the environment's dynamics. It is a function that defines the probability of moving to a successor state after taking action in state :
For any given state-action pair , the probabilities of transitioning to all possible next states must sum to one, forming a valid probability distribution:
Given your background in linear algebra, it's useful to think about how this is represented for a finite MDP. The entire transition kernel can be stored as a 3D tensor (or a three-dimensional array) with dimensions . Each "slice" of this tensor for a fixed action is a transition matrix of size , just like the one we saw for Markov Chains.
3. The Reward Function ()
The reward function defines the goal of the problem. It specifies the immediate value signal the agent receives. There are a few common conventions:
- The most general form depends on the full transition: , representing the reward received after transitioning from state to state by taking action .
- A more common form is the expected reward for a state-action pair, . This is the value we'll typically work with. It's the expectation of over the possible next states :
This expected reward function can be represented as a matrix of size .
4. The Discount Factor ()
We introduced in the last lesson as a way to make future rewards less valuable than immediate ones. Let's delve deeper into the motivations for this. David Silver's lecture offers an excellent summary of why discounting is a cornerstone of the MDP framework.
RL Course by David Silver - Lecture 2: Markov Decision Process
Let's explore the motivations behind the discount factor \gamma in more detail. This segment of the lecture provides a clear and intuitive discussion on the topic.
Watch the part of the video from "Why should we do this?" up to the start of his discussion on undiscounted processes. He covers several key reasons, including mathematical convenience, modeling uncertainty about the future, and its connection to financial and even biological systems.
To summarize the key points from the video:
- Mathematical Convenience: Using ensures that the sum of rewards over an infinite horizon (the return) remains finite, which makes the analysis and algorithms tractable.
- Uncertainty: Discounting can implicitly model uncertainty about the future. If we don't fully trust our model's long-term predictions, it's prudent to prioritize shorter-term rewards.
- Real-World Analogs: Discounting naturally models financial settings (interest rates) and has been observed in the decision-making of both humans and animals, who often exhibit a preference for immediate gratification.
The choice of fundamentally shapes the agent's behavior. A value close to 0 creates a "myopic" or short-sighted agent, while a value close to 1 creates a "far-sighted" agent that gives nearly equal weight to rewards far in the future.
5. The Initial-State Condition ()
Finally, we need to specify how the process begins. This is defined by an initial state distribution , a probability distribution over the state space .
In many cases, the process starts in a single, fixed state . This is just a special case where and for all other states. For a finite MDP, is simply a vector of length whose elements are non-negative and sum to 1.
Example: Specifying a Grid World MDP
We have now defined all the abstract components. To make this concrete, let's see how these components are specified for a simple "tabular" MDP, where the states and actions are discrete and we can write down the probabilities and rewards in tables. The following video provides a perfect walkthrough.
Reinforcement Learning Theory: Markov Decision Process
The process of creating explicit tables for the transition probabilities and rewards is exactly what it means to specify a tabular finite MDP. This video demonstrates this process for a simple grid world.
Watch the segment from the start of the table representation through the end of the 3x3 maze example. Focus on how the rules of the environment (e.g., "85% chance of success, 15% chance of slipping") are translated into specific numbers in the transition probability tables. Also, note how the rewards and initial state are defined in their own simple tables.
As the video demonstrated, specifying the MDP means filling out these tables. For each state and action, we must define the probability of landing in every possible next state. For example, from state 2, if the agent chooses action 'North', it hits a wall. The rules dictate it stays in state 2 with 85% probability, and the remaining 15% is split among slipping to adjacent non-wall states. Writing this down for all state-action pairs fully specifies the transition kernel . The same is done for the reward function and initial state distribution .
Conclusion
In this lesson, we have moved from concept to formal specification. We have established that a finite, stationary, discounted MDP is fully defined by the tuple . We broke down each component:
- The finite sets of states () and actions ().
- The transition kernel (), a function mapping state-action pairs to a probability distribution over next states, representable as a 3D tensor.
- The reward function (), which provides the immediate value signal, often given as an expected value for each state-action pair.
- The discount factor (), which determines the agent's planning horizon and ensures mathematical convergence.
- The initial state distribution (), which specifies where the process begins.
This formal blueprint is the starting point for all planning algorithms. Before we can find an optimal policy, we must first be able to describe the world in this precise language.
In our next lesson, we will take a closer look at the most foundational assumption underlying this entire framework: the Markov property. We will explore what it means for a state representation to be "Markov" and why this is so critical for making MDPs a useful model of reality.