Skip to main content
Deep Reinforcement Learning

Markov Decision Processes

Published: 2026-07-18
Level: postgraduate
Audience: Postgraduate students in Deep Reinforcement Learning

Prerequisite Knowledge

This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.

Previously Covered in This Subject

  • Reward and return — covered in Lecture 1 (From Reward to Return, 1.8)
  • Policy — covered in Lecture 1 (Policy: The Agent's Way of Working, 1.9)
  • Value function — covered in Lecture 1 (Value Function: Long-Term Desirability, 1.10)
  • Greedy action selection — covered in Lecture 1 (Choosing Moves: Greedy Action Selection, 1.16)
  • Epsilon-greedy exploration — covered in Lecture 1 (A Common Exploration Strategy: epsilon-Greedy, 1.22) and Lecture 2 (epsilon-Greedy Action Selection, 2.17)
  • Agent-environment interface — covered in Lecture 2 (The Agent-Environment Interface, 2.2)
  • State value function V(s) — covered in Lecture 2 (State Value Function V(s), 2.4)
  • Action value function Q(s, a) — covered in Lecture 2 (Action Value Function Q(s, a), 2.5)
  • Why multi-armed bandits are stateless — covered in Lecture 2 (Why MAB is "Stateless", 2.13)
  • Non-stationary bandit problems — covered in Lecture 3 (Non-Stationary Bandit Problems, 3.4)
  • Upper Confidence Bound (UCB) — covered in Lecture 3 (Upper Confidence Bound Action Selection, 3.8)
  • Contextual bandits — covered in Lecture 2 (When MAB is Not Enough: Contextual Bandits, 2.34) and Lecture 3 (Contextual Bandits: Bridging MAB and Full RL, 3.10)

Markov Decision Processes

4.1 Recap and Transition to Full Reinforcement Learning

4.1.1 What We Have Covered So Far

Hook: You have been playing a slot machine with many arms. You learned which arm pays best. But what if the best arm changes depending on where you are standing? That is the jump we are about to make.

Before looking at full RL, let us recap the key ideas from the multi-armed bandit formulation. These ideas carry forward and will appear again.

A multi-armed bandit is a simplified RL problem. You have several actions (arms). You pull one and get a reward. You track how good each action is — this is the value of an action. You learn which arm pays best over time.

You learned two ways to pick actions:

  • Greedy — always pick the best-known action.
  • Random — sometimes explore other actions to see if they are better.

This creates the exploration versus exploitation trade-off. You start knowing nothing, so you must explore. As you learn, you want to exploit what you know. Epsilon-greedy action selection (ε-greedy) handles this: with probability ε you explore randomly, with probability 1−ε you pick the best-known action. The UCB (Upper Confidence Bound) method is smarter — it balances exploration by accounting for uncertainty in action-value estimates. Arms you have not tried much get a bonus because their true value is uncertain.

You also covered stationary versus non-stationary problems. In a stationary problem, the reward distributions never change. In a non-stationary problem, they shift over time. Your learning approach must adapt — for example, by using a step-size parameter that weights recent rewards more heavily.

Finally, you looked at contextual bandits. Here, extra information (context) helps inform your action choice. But the choice is still not tied to a state — the context does not change based on your action.

Q: Is UCB particularly important for the exam?

A: Yes — UCB, exploration versus exploitation, epsilon-greedy, and the stationary/non-stationary distinction are the things you should be very well versed with and revisit before the exam.

4.1.2 Entering Full Reinforcement Learning: States

Hook: In a bandit, you stand in one spot and pull arms. In full RL, the world around you changes based on what you do. Your next decision depends on where you ended up.

In the multi-armed bandit problem, there is no notion of states. You simply pull one of the available actions and track values. Now we add a new ingredient: states. You must select actions in the context of a state.

Think of autonomous driving. The car is driving uphill. The slope is steep. There is a vehicle ahead. All these contribute to the state. When you want to know what action to take, you look at the current state. In soccer-playing robots, each robot must choose actions based on the current game state. In portfolio management, the system must consider what is happening in the world, in the company, and in your profile to recommend buy, sell, or hold.

Intuition + Analogy: A bandit is like a fixed slot machine — you stand in one place and pull levers. Full RL is like navigating a maze — each move changes your position, and the right move depends on where you are now. The analogy breaks down because in RL the maze itself can be stochastic: the same move might land you in different places.

The key shift: your job is always to take an action given a state. You never take an action in isolation. The action selection is coupled with states. In bandits, you estimate — the value of action . In full RL, you estimate — the value of action in state . That extra dimension is what makes RL richer and harder.

4.2 Course Roadmap

4.2.1 Next Three Classes

The next three classes follow a logical chain:

  1. Markov Decision Processes (MDP) — a formal, mathematical way to define an RL problem. You will learn what an MDP is, how to model a problem using it, and study key mathematical definitions including Bellman equations.
  2. Solving MDPs — once the problem is specified as an MDP, you can solve it using dynamic programming, learning-based approaches, data-driven statistical solutions, and more.
  3. Dynamic Programming (DP) solution — the first solution approach, applied when the full MDP is known.

Think of it as: define the problem (MDP), write the equations (Bellman), then solve them (DP). These three steps are what you will cover.

4.2.2 Agent-Environment Interface Refresher

Hook: Every RL problem has the same shape — an agent acts, the world responds, and the agent learns from the feedback. Understanding this loop is the foundation for everything that follows.

Before looking at MDP, recall the agent-environment interface. The agent is at the center of every RL problem. The agent interacts with the environment. The environment gives feedback. The agent chooses actions to maximize the cumulative rewards it accumulates over the long term — the return.

It is not merely about the immediate reward. Sometimes a large immediate reward leads to nothing afterward. Smaller sustained rewards over time can add up to much more.

Intuition + Analogy: Think of a chess game. Each move (action) changes the board (state). You get no reward until the end (win/lose/draw). A flashy sacrifice might feel good but lead to a loss. The agent must think long-term, not just about the next move. The analogy breaks because in RL rewards can come at every step, not just at the end.

The interaction sequence looks like this:

  • Start at state
  • Take action
  • Environment responds with reward and new state
  • Take action
  • Environment responds with reward and new state
  • Take action
  • Environment responds with reward and new state

And this repeats. This trajectory — — is the fundamental sequence of RL. Every concept in this lecture builds on it.

4.3 The Markov Property

4.3.1 Definition and Intuition

Hook: How much of the past do you need to remember to make a good decision right now? The Markov property says: only the present matters.

When you take an action at a given point — say at state — you look only at the most recent state. You do not look at the entire history (). The state must satisfy the Markov property: it must contain everything necessary to make an action decision.

Intuition + Analogy: Think of a board game like chess. To decide your next move, you only need the current board position — not the sequence of moves that led to it. The board position is Markov because it captures everything relevant. If you also needed to know "how many moves ago did the opponent castle?" then the board alone would not be Markov — you would need to add that information to the state. The analogy breaks because in RL the "board" can include hidden information like battery levels or sensor readings.

The state must cover, must represent, everything that is necessary to make an action selection. If you need to know battery level, the state must include battery level. If the road condition matters, the state must capture it.

Formally, the Markov property holds when:

This means: given the current state and action , knowing the full history does not add any extra information about what comes next. The current state is a sufficient summary of the past.

Pitfall: The Markov property is a property of the state representation, not of the problem itself. If your state does not capture enough information, the Markov property fails. The fix is to redesign the state — add the missing information. For example, if the agent's speed matters but is not in the state, add it.

4.3.2 Testing the Markov Property: Battery Level

Consider a grid world. The simplest state description is just your location — where you are now (row and column). But suppose the battery is almost dead. If you take no action and wait, you might get recharged. If you move left or right blindly, you might fall into a pit and lose a large penalty.

So sometimes including battery level as part of the state helps. It lets the agent make smarter decisions.

Worked Example: Suppose you are at cell (2, 3) in a grid world.

  • State = location only: (2, 3). The agent does not know the battery level. It might move and drain the battery, falling into a pit.
  • State = location + battery: (2, 3, low). Now the agent knows the battery is low. It can choose to wait and recharge instead of moving blindly.

The second state is Markov — it contains everything needed for a good decision. The first is not Markov — the missing battery info could change the best action.

The state description is a design choice: location alone or location plus battery level. You must check: does my state capture everything that affects what happens next? If yes, it is Markov. If no, add the missing information.

The Markov property is about sufficiency. The state must be a sufficient summary of the past for predicting the future. If it is not, enrich it.

4.4 Grid World Example

4.4.1 Environment Setup

Hook: Imagine a maze where the floor might crumble under your feet. You cannot always control where you end up. That is the grid world — a simple playground where we test RL ideas before scaling up to real problems.

Here is a grid world. An agent starts somewhere in the grid. The grid has:

  • Cells where the agent can be at any time.
  • A pit — if the agent steps in, there is no way out. No matter which direction you move, you stay trapped.
  • Terminal states — reaching one specific state gives +1, another gives −1.
  • The agent cannot leave the environment — walls block movement.

Intuition + Analogy: Think of the grid world as a board game on a chessboard. Some squares are safe, some are traps (the pit), and some are goals (+1 or −1). The agent is a game piece. The twist: when you try to move, the piece might slide in a different direction. The analogy breaks because in a real board game you control your piece exactly — here, actions are noisy.

4.4.2 Actions

The agent has four actions: up, down, left, right. These actions are noisy — not deterministic. If you press up:

  • 80% of the time, you go up as intended.
  • 20% of the time, the move fails and you go to one of the other three directions (10% to left, 10% to right — the exact split across remaining directions depends on the specification).

Pitfall: Do not confuse "noisy actions" with "wrong actions." The agent is not making a mistake — the environment is stochastic. Even the best action can fail. This is why we need probabilities, not just rules.

This uncertainty captures that in the real world, actions do not always work as planned. When you press the brake in a car, 99% of the time the car stops. 1% of the time, something unexpected happens. When you drive in bumper-to-bumper traffic in first gear, things usually move as expected, but there is a chance the clutch gets stuck. You can factor that uncertainty in.

4.4.3 Rewards

The environment gives back rewards. To encourage reaching the goal quickly (before the "battery dies"), you give −1 for every step the agent takes. Reaching a good terminal gives +1. Reaching a bad terminal gives −1 (or even −100 if you want to heavily penalize it).

Worked Example: Suppose the agent is 3 steps from the +1 goal and 2 steps from the −1 pit.

  • Path to goal: 3 steps × (−1) + (+1) = −2
  • Path to pit: 2 steps × (−1) + (−1) = −3

The agent should prefer the goal path (−2 > −3). But with noisy actions, it might accidentally fall into the pit. The agent must plan for uncertainty.

Sense-check: The per-step penalty of −1 makes the agent prefer shorter paths. Without it, the agent might wander forever.

This reward design is intentional. The −1 per step acts like a ticking battery — it nudges the agent to find the shortest path. It is a common trick in RL: small negative rewards for each step encourage efficiency.

4.5 The Elements of MDP

4.5.1 Overview

Hook: Every RL problem, from a game of chess to a self-driving car, can be broken into the same five ingredients. Learn these five, and you can model any sequential decision problem.

To model a problem as an MDP, you must pin down these elements:

  1. State space — the set of all possible states.
  2. Action space — the set of all possible actions, and whether they are deterministic or noisy.
  3. Model dynamics (transition probabilities) — how the environment behaves in response to your action.
  4. Reward function — what the environment gives back.

These are the first four elements. The fifth — policy — is what you want to learn. Let us examine each.

4.5.2 Element 1: State Space

The state space is the set of all possible states. The state is what you track about the environment. In the grid world, it can be just your location (row, column) or location plus battery level. The choice of what goes into the state is a design decision.

Intuition + Analogy: The state is like a medical chart. A doctor decides what information to include — blood pressure, heart rate, allergies. Include too little, and you miss something critical. Include too much, and the chart is hard to read. The art is choosing the right level of detail. The analogy breaks because in RL the state must satisfy the Markov property — it must be sufficient for the decision at hand.

For a traffic signal control problem, the state might include queue lengths at each lane, average waiting times, and current phase. For a video game, the state might be the last three frames concatenated — this captures motion direction, not just a static image.

4.5.3 Element 2: Action Space

The action space lists all possible actions available in state . Actions may be:

  • Deterministic: the outcome is always the same.
  • Noisy (stochastic): the outcome has a probability distribution.

For the traffic signal, actions might be: extend the current phase, or switch from phase 1 to phase 2 (if admissible). There are eight possible phases (valid green-light combinations for the intersection).

4.5.4 Element 3: Reward Function

The reward function maps state-action-next-state triples to a scalar number. The reward is a single scalar signal. The environment does not give back a detailed report card — it gives one number. That number is the basis for all learning.

Pitfall: The reward signal is not the place to tell the agent how to achieve the goal. It should only signal what the goal is. If you reward sub-goals (like "take opponent's pieces" in chess), the agent might exploit those rewards without winning the game.

The reward signal must indicate what is expected good behavior. If you reward wrong actions, you train a wrong agent. For example, in an office, if you are never penalized for poor performance, your behavior adjusts accordingly. The reward function should direct the agent toward the desired behavior.

Designing the right reward function often requires significant expertise. In traffic signal control, if your objective is to give a reasonable waiting time to all lanes:

  • Reward could be the negative of average delay. If delay is more, the negative reward is worse.
  • Or it could be the negative of queue length.

Q: Who decides the rewards when programming an RL system?

A: The signals come from the environment. In autonomous driving where your priority is a smooth drive, moderate speed, and respecting lane lines, you must take all these aspects, weight them, and make one number. The world does not give you a single ready-to-use number. The RL engineer extracts cues from the world and formulates that single scalar reward.

Exam note: The reward function drives the learning. A badly designed reward function trains a badly behaving agent. Expect questions on how to design rewards for specific tasks.

4.5.5 Element 4: Model Dynamics (Transition Probabilities)

4.5.5.1 Formal Definition

Symbol Registry — Model Dynamics

  • — current state — — one of the finite set of states
  • — action taken — — one of the actions available in state
  • — next state — — the state the environment transitions to
  • — reward — — scalar reward
  • — model dynamics — — probability of landing in with reward

The model dynamics is a big table of probabilities. It says: if you are in state and take action , what is the probability of ending up in state with reward ?

Intuition: Think of the model dynamics as a weather forecast for every possible day. If today is sunny (state) and you carry an umbrella (action), what is the chance you end up dry (next state) with happiness (reward)? The model dynamics is that complete forecast for every state-action pair.

For all states and all possible actions in each state, if this behavior is defined, you have a complete description of how the environment behaves — you have an MDP.

The textbook (Sutton & Barto, §3.1) defines this as equation (3.2) and notes that is a deterministic function of four arguments. The probabilities from a given pair must sum to 1:

This is the normalization constraint. It ensures the model dynamics is a valid probability distribution.

4.5.5.2 Interpreting the Model Dynamics Table

Worked Example: You are in state . The actions available are start and stop.

start 4 0.6
start 2 0.2
start 0 0.2
stop 1 1.0

Verifying a proper table: For a given pair, all probabilities must sum to 1.

For : . Valid.

For : . Valid.

Sense-check: From , taking start can lead to (with reward 4 or 2) or stay at (with reward 0). Taking stop always goes to with reward 1. The table captures all possible outcomes.

4.5.5.3 Visualization of Model Dynamics

Assume you are in state and you take action . There are two ways to visualize what happens:

Deterministic case (probability = 1):

You go to with reward 7 for sure.

Stochastic case:

Pressing the brake in a car — you are in a state and take action "brake":

  • With probability 0.95, the car stops (), reward +100.
  • With probability 0.05, the car does not stop (), reward −1000.

The model dynamics captures this uncertainty. Think of applying for a promotion. The outcomes could be: get promoted with 5% increment, get promoted with 20% increment, or not get promoted. Each has a probability.

Q: In the car braking example, is the 5% failure (sliding/skidding) an inherent property of the car itself, or is it due to driving on a snowy road?

A: The answer lies in what the state captures. If the state says "snowy road," the model dynamics for the same brake action should evoke different behavior from the environment. The state must describe the road condition. The model dynamics can be different for the same action in different states.

Q: The model dynamics table shows discrete rewards, but rewards are often continuous. How do we handle that?

A: For ease of explanation, we are discussing finite Markov Decision Processes where states, actions, and rewards are all finite and discrete. This is an assumption made for communication. Real-world problems often have continuous states and rewards — those go beyond finite MDPs.

Scope: Everything in this lecture assumes a finite MDP. The state space , action space , and reward set are all finite. This is a simplification for learning. Real problems often need continuous spaces and function approximators.

The model dynamics is the complete description of how the environment works. If you know it, you know everything about the problem. The challenge is that in most real problems, you do not know it — you must learn it or work around it.

4.6 Deriving Quantities from Model Dynamics

4.6.1 State Transition Probabilities

Hook: The model dynamics table gives you the full picture — next state AND reward together. But often you only care about where you end up, not the reward. Can you extract just the movement probabilities? Yes, by summing over rewards.

From the full model dynamics table, you can sum over all possible rewards to get the state transition probability:

Intuition: Think of it like this: you applied for a promotion (action) from your current role (state). The model dynamics tells you the chance of each outcome and each reward together. But if you only want to know "what is the chance I get promoted?" — regardless of the increment amount — you sum over all possible rewards. This collapses the joint probability into a marginal over next states.

Worked Example: Using the table from section 4.5:

From , taking start, going to :

From , taking start, going to :

From , taking stop, going to :

Verification: For : . For : . Both sum to 1. Valid.

Sense-check: From , taking start, you go to with 80% chance and stay at with 20% chance. This matches the intuition that start usually moves you forward.

The textbook (Sutton & Barto, §3.1, eq. 3.4) defines this as:

This is a marginalization — you collapse the reward dimension out of the joint distribution.

4.6.2 Expected Immediate Reward

You can compute the expected immediate reward for a given state-action pair. This tells you: on average, how much reward do I get right now if I take action in state ?

The outer sum is over all possible rewards. The inner sum is over all possible next states. For each reward value , you weight it by the total probability of getting that reward (summed over all next states).

Worked Example: For :

For :

Sense-check: Starting from and taking start gives an average reward of 2.8. Taking stop gives 1.0. The start action is more rewarding on average, which makes sense — it leads to outcomes with rewards 4 and 2 most of the time.

The textbook (Sutton & Barto, §3.1, eq. 3.5) defines this as:

Note: the textbook uses with the previous state , while the lecture uses with . Both are equivalent — just a difference in time-indexing convention. The lecture convention is more common in RL courses.

4.6.3 Expected Reward for a Specific Transition

Hook: Sometimes you want to know: "I am in state , I took action start, and I ended up in state . What reward should I expect?" This is a conditional expectation — conditioned on a specific next state.

You can ask: "I applied for promotion, and I got promoted. What is my expected increment?"

Chances of getting promoted = .

Among the 80% of cases where you get promoted:

  • 60% of the time, the reward is 4.
  • 20% of the time, the reward is 2.

Worked Example: The expected reward given the promotion happens is:

Sense-check: Given that you got promoted, the expected increment is 3.5. This is between 2 and 4, weighted toward 4 because the higher increment (4) is more likely (75% vs 25%).

More formally, the expected reward for a state-action-next-state triple is:

This is Bayes' rule in action. You divide the joint probability of by the marginal probability of to get the conditional expectation of given .

The textbook (Sutton & Barto, §3.1, eq. 3.6) defines this equivalently.

The model dynamics table lets you compute many things beyond what is directly written in it.

4.6.4 Complete Numerical Example: Start–Stop MDP & Deterministic Special Case

Step-by-Step Derivation of All Quantities (Start–Stop MDP):

Step 1: Check Probability Validity

For : .

For : . Valid probability model.

Step 2: Transition Probabilities

Step 3: Expected Immediate Rewards

Step 4: All Conditional Expected Rewards

Step 5: Deterministic Special Case

If both actions have exactly one deterministic outcome:

Summary Comparison Table of Quantities:

Quantity Mathematical Formula Meaning in Start–Stop Example
Full joint probability of next state and reward together (e.g., ).
Transition probability after marginalizing out reward (e.g., ).
Average immediate reward for choosing action in state (e.g., ).
Average immediate reward when next state is also fixed (e.g., ).

From the single model dynamics function , you can derive: state transition probabilities , expected immediate rewards , and conditional expected rewards . The model dynamics is the master table.

4.7 Finite vs Infinite MDP

4.7.1 The Finite MDP Assumption

Hook: We have been talking about tables of probabilities. But what if the table has a billion rows? You cannot store it. That is the gap between finite MDPs and the real world.

For communication purposes, the discussion focuses on finite MDPs where the sets of states, actions, and rewards are all finite. This is not the general case. Real-world problems may have:

  • Continuous state spaces (sensor readings, camera inputs, queue lengths).
  • Continuous rewards (not just discrete numbers like 4, 2, 0, 1).

Intuition + Analogy: A finite MDP is like a board game with a fixed number of squares and dice outcomes. You can list every possibility. A continuous MDP is like driving on a highway — your speed, position, and the distances to other cars are real numbers. You cannot list every possible state. The analogy breaks because even continuous problems can sometimes be discretized for approximation.

In the traffic signal example, queue lengths and waiting times are real numbers, not discrete categories. The reward is the negative of delay, which is continuous. The state space is huge. You cannot enumerate all states to build a table — the transition dynamics must be modeled differently (e.g., using a function approximator).

Scope: The finite MDP assumption is a teaching tool. It lets us define as a table. In practice, most interesting problems violate this assumption. But the concepts — states, actions, rewards, transitions, policies, value functions — carry over to the continuous case. You just need different computational tools (function approximators, neural networks, etc.).

But starting with finite MDPs teaches the core ideas before scaling up.

Finite MDPs are the foundation. The concepts generalize to continuous spaces, but the math tools change. Learn the finite case first.

4.8 Example MDP Formulations

4.8.1 Video Game (Atari-style)

Hook: How would you teach a computer to play a video game it has never seen? You define what it sees (state), what it can do (actions), and what "doing well" means (reward). That is MDP formulation.

MDP Formulation — Atari Video Game:

  • State: Representation of recent frames. The current frame alone, or the last three to five frames concatenated. Including multiple frames lets the agent model motion direction — a single frame is a static image, but three frames show which way things are moving.
  • Actions: Left, right, up, down (joystick moves).
  • Reward: The score increment shown on screen. If the score goes from 20 to 23, the reward is +3. If you lose a life, it goes negative.
  • Transition: The emulator takes your action, applies it to the game, and returns the new screen configuration. The transition is deterministic given the game engine — but the agent does not know the engine, so it must learn.
  • Policy: A rule that maps the current state (screen frames) to an action (joystick move).

Worked Example: Suppose the current score is 150. The agent moves right and destroys an enemy. The new score is 160. The reward is . The new state is the new screen (or the last 3 frames including this one).

If the agent moves right and gets hit by an enemy, the score drops from 150 to 150 (no change) but a life is lost. The reward might be −100 (penalty for losing a life).

4.8.2 Traffic Signal Control

MDP Formulation — Traffic Signal Control:

  • State: Queue lengths and average waiting times for each lane. These are extracted from camera inputs and reduced to numbers. For a four-lane intersection, the state is a vector of queue lengths plus a vector of waiting times.
  • Actions: The intersection has eight possible phases (valid green-light combinations). Actions are: extend the current phase, or switch from the current phase to an admissible next phase.
  • Reward: Depends on the objective — negative of average delay, negative of maximum queue length, or maximization of throughput. The choice requires domain expertise. The reward function drives the learning, so it must be designed carefully.
  • Transition: Highly complex — cannot be stored as a table. Requires a probabilistic function or simulator. Traffic flow depends on time of day, events, weather, and more.
  • Policy: What the learning produces — a mapping from current state to action.

Pitfall: The state space for traffic signals is enormous. Queue lengths are real numbers. You cannot enumerate all states. This is where finite MDP theory breaks down in practice — you need function approximators (like neural networks) to handle it.

4.8.3 Recycling Robot (Textbook Example 3.3)

Symbol Registry — Recycling Robot

  • High — high battery level — state
  • Low — low battery level — state
  • search — action: actively look for cans — available in both High and Low
  • wait — action: stay in place and wait for cans — available in both High and Low
  • recharge — action: recharge the battery — available in Low only
  • — probability battery stays High after searching —
  • — probability battery stays Low after searching —
  • — reward for searching (securing a can) — scalar
  • — reward for waiting — scalar (smaller than )
  • — penalty (−3) when battery is fully exhausted and must be rescued — scalar

This is Example 3.3 (boxed) from the Sutton & Barto textbook. It is a high-level decision-making agent. A recycling robot has sensors to detect cans and an arm with a gripper to pick them up and drop them in a bin. It runs on a rechargeable battery. The objective is to decide how to search for cans based on the current battery charge level.

Intuition: The recycling robot is like a person with a phone battery. When the battery is high, you can browse freely. When it is low, you must decide: keep browsing (search), put the phone down (wait), or plug it in (recharge). If you browse too long at low battery, the phone dies and you lose time (the −3 penalty for being rescued).

States: Two battery levels — high and low. (The state only tracks battery because battery drives all decisions.)

Actions:

  • When battery is High: search or wait.
  • When battery is Low: search, wait, or recharge.
  • Recharging is not allowed when the battery is already high.

Rewards: The robot gets nothing most of the time. It gets a reward only when it secures a can. Searching yields far more cans than waiting — waiting means a can is dropped next to the robot by someone else. The reward for searching () is greater than the reward for waiting ().

Model Dynamics (visualized as a graph):

  • From High, taking wait: with probability 1, you stay in High and get reward . Only one outcome.
  • From High, taking search: two outcomes.
    • Battery stays High with probability , reward .
    • Battery goes Low with probability , reward .
  • From Low, taking wait: with probability 1, you stay in Low and get .
  • From Low, taking search: two outcomes.
    • Battery stays Low with probability , reward .
    • Battery gets fully exhausted with probability . The robot is rescued, gets a penalty of −3, and is taken back to High (battery recharged by the rescuer).
  • From Low, taking recharge: with probability 1, go to High. Get no cans (reward = 0).

Worked Example — Transition Table:

High search High
High search Low
High wait High 1
Low search Low
Low search High −3
Low wait Low 1
Low recharge High 1 0

Verification: Each pair has probabilities summing to 1. For (High, search): . For (Low, search): . Valid.

Sense-check: Searching from High is safe (no risk of exhaustion). Searching from Low risks the −3 penalty. Recharging is safe but yields no reward. The robot must balance collecting cans against the risk of running out of battery.

Q: Does this MDP formulation resemble finite state machines from automata theory?

A: At a high level of abstraction, yes — both use states, actions, and transitions. But there is a critical difference: Turing machines and automata are deterministic — a given input always produces the same output. MDPs are probabilistic. The same action from the same state can lead to different outcomes with different probabilities. Keep these separate for now.

Q: How is this different from a contextual bandit?

A: In a true contextual bandit, actions are not tied to the context. Context provides additional information for your decision — like knowing it is raining might change your playlist choice in the car but not your driving actions. In MDP, the action you take depends directly on what the current state is. The action is always taken given the state ( — never separated). Your driving actions (brake, accelerate) depend on the road state. Your playlist choice depends on the passenger context. These are two different decision layers. The line is subtle, and you must be careful when modeling — decide whether a factor is a context (additional info) or a state (drives action choice).

Pitfall: Do not confuse contextual bandits with MDPs. In a contextual bandit, the context does not change based on your action. In an MDP, the state transitions depend on what you do. The key test: does your action affect the next state? If yes, it is an MDP. If no, it is a contextual bandit.

Any sequential decision problem can be formulated as an MDP by defining states, actions, transitions, and rewards. The art is choosing the right level of detail for states and the right reward function.

4.9 Reward Hypothesis and Return

4.9.1 The Reward Hypothesis

Hook: What is the one thing every RL agent cares about? A single number. That number is the reward. Everything else — states, actions, policies — exists to maximize that number over time.

The Reward Hypothesis: Every RL problem can be thought of as the maximization of the expected value of the cumulative sum of the received scalar signal (reward).

Breaking this down:

  1. Reward — a scalar number the environment gives back.
  2. Cumulative sum — we add up rewards over time, not just the immediate one.
  3. Expected value — the future is unknown, so we maximize what we expect to get, on average.

The textbook (Sutton & Barto, §3.2) states this as: "all of what we mean by goals and purposes can be well thought of as the maximization of the expected value of the cumulative sum of a received scalar signal (called reward)."

If the reward function is formulated wrongly, the entire learning goes wrong. The cumulative sum matters because you want sustained good behavior, not just one lucky reward spike.

Pitfall: Do not reward sub-goals. If you reward a chess agent for taking pieces, it might take pieces and still lose. The reward should reflect the true goal: winning the game.

4.9.2 Return: Simple Sum

The return is the sum of all future rewards from time step . It is what the agent wants to maximize.

Assume you are at time step and in state . The return is:

This is a simple sum. Every future reward is weighted equally.

Intuition: Think of the return as your total salary over a career. If you earn ₹50,000 every month for 30 years, your return is . Every month counts the same.

The problem: if the horizon is infinite and rewards are positive, this sum can diverge to infinity. That is where discounting comes in.

4.9.3 Return: Discounted Sum

A more common definition uses a discount factor (gamma, between 0 and 1) to give more importance to the present than the future:

Every symbol named:

  • — the return from time step
  • — the reward received steps into the future
  • — the discount factor,
  • — the index of summation, starting from 0

The discount factor controls how much you value future rewards:

  • : You are a hedonist — only the immediate reward matters. Everything beyond now is ignored. .
  • : You are a yogi — present and future are equal. No discounting. .
  • Typically, is close to 1 (e.g., 0.9, 0.95, 0.99) — you care about the future but discount it slightly.

Why discount?

  1. Mathematical guarantee: With an infinite horizon, a simple (undiscounted) sum can go to infinity. If every reward is 1, the sum . With discounting (): . For , this is — a finite number. This ensures you can always compare values between states without facing infinities.
  2. Intuition: ₹1000 today is worth more than ₹1000 two years from now. The further into the future, the less certain the outcome, so you discount it.
  3. Practical comparison: Consider choosing between a 20 km detour for great coffee versus nearby average coffee. Even though the great coffee is "better," the cost of the detour diminishes its net value. Discounting captures this intuition.

Worked Example — Discounted Sum: Suppose and the reward sequence is , , , , , with .

Working backwards:

Sense-check: means the total discounted return from the start is 2. The early negative reward is outweighed by the later positive rewards.

Q: Why discount the future? Why not discount the past?

A: The past is irrelevant — you are in state now. What happened before you got there does not matter for what you should do next. Only what comes after matters. And discounting the future prevents infinite sums when the horizon is unlimited.

Q: How far ahead do we sum? The number of steps is undefined.

A: You do not need to define a stopping point. The discount factor ensures the sum converges to a finite value. In continuous control (like a nuclear reactor that runs forever), you never stop — but with , the sum is mathematically guaranteed to be finite. In episodic tasks where the horizon is known and finite (e.g., 1000 steps), discounting is less critical — a simple sum works. But the standard formalism uses discounted return for consistency across both episodic and continuous problems.

Exam note: The discounted return formula and the recursive form are fundamental. Expect to compute returns by hand given a reward sequence and a discount factor.

4.9.4 Recursive Form of Return

The discounted return has a clean recursive form:

This is one of the most important equations in RL. It says: the return from now equals the immediate reward plus the discounted return from one step later.

The derivation is straightforward:

Step by step:

  1. Write out the full discounted sum.
  2. Factor out of everything after the first term.
  3. Recognize that the bracketed expression is .

Intuition: Think of Russian nesting dolls. The big doll () contains the immediate reward () and a smaller doll () scaled down by . That smaller doll contains its own immediate reward and an even smaller doll, and so on. Each doll is a scaled copy of the next.

This recursion is fundamental. It will appear again in the Bellman equations. The current return equals the immediate reward plus the discounted return from the next state onward. summarizes the entire future.

Pitfall: Do not forget that depends on the rewards from time onward, not from . The reward is not part of . The return is the sum starting with .

4.10 Episodic vs Continuous Tasks

4.10.1 Classification

Hook: Does the game ever end? That single question changes how you define the return, how you design the reward, and whether you need a discount factor.

Tasks fall into two categories:

  • Episodic tasks: The interaction has a natural endpoint. Each episode ends in a terminal state. After the episode ends, you reset and start a new one. Example: a game of chess — it ends at checkmate or draw. Another example: a maze — the episode ends when you reach the exit or fall into a trap.
  • Continuous tasks: The interaction goes on forever with no natural endpoint. Example: controlling a nuclear reactor, or a robot that must balance a pole indefinitely.

Intuition + Analogy: Episodic tasks are like rounds in a boxing match. Each round ends, you rest, and a new round starts. Continuous tasks are like a marathon — you run until you cross the finish line, but there is no "restart" in the middle. The analogy breaks because in RL, continuous tasks literally never end.

The textbook (Sutton & Barto, §3.3) notes that in episodic tasks, the return is a finite sum (up to the terminal time step ), while in continuous tasks, the return is an infinite sum that needs discounting to stay finite.

4.10.2 Cart-Pole Balancing Example

Worked Example — Cart-Pole as Episodic vs Continuous:

Consider the cart-pole problem. A pole is mounted on a cart. The cart must move left and right to keep the pole balanced. The pole can fall in either direction.

Episodic modeling:

  • Episode starts with pole upright.
  • Episode ends when the pole falls past a threshold angle.
  • Reward: +1 for every time step the pole stays up.
  • Return: total number of steps before failure. No discounting needed ( works because the episode is finite).
  • Goal: maximize the length of the episode.

Continuous modeling:

  • The task runs forever — the pole is reset instantly when it falls.
  • Reward: 0 for each step the pole is balanced, −1 when it falls.
  • Return: with .
  • Goal: maximize the fraction of time the pole is balanced.

You can model it either way. The choice affects your reward design and whether you use a discount factor.

Scope: The choice between episodic and continuous is a modeling decision, not a property of the physical task. The same cart-pole can be modeled either way. The choice affects reward design, discount factor, and the algorithms you can use.

Exam note: Think about reward and gamma choices for episodic vs continuous modeling. If episodic, is often fine. If continuous, you must have . The textbook notes that the convention (return at the terminal state is zero) makes the recursive form work even at the last step before termination.

4.11 Policy

4.11.1 Definition

Hook: The agent is in a state. What should it do? The policy is the answer — it is the agent's playbook, telling it what to do in every situation.

A policy is the agent's behavior rule. It maps states to actions. Formally:

This is the probability of taking action given that you are in state .

Every symbol named:

  • — the policy (the agent's behavior rule)
  • — a specific action
  • — a specific state
  • — the probability of choosing action in state
  • — the random variable for the action at time
  • — the random variable for the state at time

The textbook (Sutton & Barto, §3.5) defines policy as "a mapping from states to probabilities of selecting each possible action." The notation uses the "|" to remind us that it defines a probability distribution over actions for each state — just like conditional probability notation.

Intuition: Think of a policy as a recipe book. Each page (state) lists the ingredients (actions) and how likely you are to use each one. A deterministic policy is a recipe that says "always use flour." A stochastic policy says "70% flour, 30% cornstarch."

4.11.2 Types of Policies

Stochastic policy: The policy gives a probability distribution over actions. Multiple actions have nonzero probability.

Example: In a grid, from state :

These sum to 1: .

Deterministic policy: One action gets probability 1, all others get 0.

Example: , everything else = 0. Always go up from this state.

When a policy is deterministic, you simply follow it. When stochastic, you must sample from the distribution.

Worked Example: Suppose you are in state with the stochastic policy above. You roll a random number between 0 and 1.

  • If the number is in [0, 0.9): go up. This happens 90% of the time.
  • If in [0.9, 0.93): go left. This happens 3% of the time.
  • If in [0.93, 0.96): go right. This happens 3% of the time.
  • If in [0.96, 1.0]: go down. This happens 4% of the time.

Over 1000 steps from state , you would go up about 900 times, left about 30 times, right about 30 times, and down about 40 times.

4.11.3 Policy and Value: Visual Intuition

Consider a small grid with terminal states whose values are shown. Inside each cell is a value — a number representing the expected return from that state. The arrows indicate the dominant action from the policy — the direction with the highest probability. The policy points toward states with higher values, because following that path maximizes expected return.

Intuition: Imagine a hiker on a foggy hillside. The hiker cannot see the summit but can feel the slope under their feet. The policy is the hiker's strategy: "always walk uphill." The value of each position is how close it is to the summit. The policy points uphill because that is where the value is higher.

For a given state , the value is: if you are in that state and continue acting (according to the policy), what is the expected discounted sum of future rewards? If reaching a terminal gives +1 and intermediate rewards are 0 (discounted by each step), the value might be something like 0.64.

Key insight: you decide a policy based on these value numbers. Formally define the value function, then use it to decide the policy. This is the foundation of RL: estimate values, then act greedily on those estimates.

The policy is the agent's behavior rule. It can be stochastic (probabilities over actions) or deterministic (one action with probability 1). The policy is what the agent learns — and value functions tell the agent which policy is better.

4.12 Value Functions

4.12.1 State-Value Function

Hook: How good is it to be in this state? The state-value function answers that — it tells you the expected return if you start here and follow your policy.

The state-value function is the expected return starting from state and following policy :

Every symbol named:

  • — the value of state under policy
  • — the policy being followed
  • — the state we are evaluating
  • — the expected value over trajectories generated by following
  • — the return (discounted sum of future rewards)
  • — the condition that we start in state at time

This is textbook equation (3.12) in Sutton & Barto. The notation uses the subscript to emphasize that the value depends on the policy. A different policy gives different values for the same state.

Intuition: Think of an office. The value of your office is not the furniture — it is the expected outcome of working there. If your office is next to the boss, you might get promoted faster (higher value). If it is next to the noisy printer, you might get less done (lower value). The value is the expected return from being in that office and following your usual work routine (policy).

Pitfall: Never write without the subscript. The value of a state is meaningless without specifying the policy. is ambiguous; is precise. Always ask: "value under which policy?"

Exam note: The state-value function is fundamental. Be ready to define it, name every symbol, and explain why the policy subscript matters.

4.12.2 Action-Value Function

The action-value function is the expected return starting from state , taking action , and then following policy :

Every symbol named:

  • — the value of taking action in state under policy
  • — the state we are in
  • — the action we take first
  • — the policy followed after the first action
  • — the expected value over trajectories
  • — the return
  • — the condition that we start in state and take action

This is textbook equation (3.13). The "Q" stands for "quality" — the quality of taking a particular action in a particular state.

Intuition: Think of a job. The value of your current job (state) is the expected career outcome. But the action-value asks: "If I take this specific job offer (action) and then follow my usual career strategy (policy), what is the expected outcome?" The action-value evaluates a specific choice, not just the situation.

Pitfall: Do not confuse and . asks "how good is it to be here?" asks "how good is it to do this specific thing here?" is a function of one argument (state). is a function of two arguments (state and action). The relationship: — the state value is the policy-weighted average of action values.

The state-value function evaluates states; the action-value function evaluates state-action pairs. Both depend on the policy . These two functions are the backbone of every RL algorithm.

4.13 Bellman Expectation Equations

4.13.1 Bellman Expectation Equation for State-Value

Hook: How does the value of where you are right now relate to the values of where you might land next? The Bellman expectation equation breaks down the value of a state into immediate reward plus discounted successor values.

The Bellman expectation equation for is a fundamental self-consistency relationship:

Every symbol named:

  • — expected return from state under policy
  • — probability of choosing action in state (policy averaging)
  • — probability of environment transitioning to with reward (environment dynamics averaging)
  • — immediate scalar reward received on transition
  • — discount factor ()
  • — value of the successor state

Derivation Step-by-Step:

  1. Start with definition: .
  2. Substitute recursive return : .
  3. Condition on first action , immediate reward , and next state : average over policy choices and environment dynamics .
  4. By the law of total expectation, . Substituting gives equation (3.14) in Sutton & Barto.

Backup Diagram for :

A backup diagram visualizes how values flow backward from future state-action outcomes to the current state:

  • Root node: state (open circle).
  • Branches: action choices selected according to policy (solid dots).
  • Sub-branches: environment transitions to next states (open circles) returning reward with probability .

The value at root is the expected average over all branches.

4.13.2 Bellman Expectation Equation for Action-Value

Similarly, the Bellman expectation equation for is:

Here, after taking action in state , the environment moves to state with reward . From , future action choices are selected according to .

4.13.3 Conversion Between and

The state-value function is the policy-weighted average of action-value functions:

Conversely, the action-value function is the environment-weighted expectation of immediate reward plus discounted successor state-value:

4.14 Gridworld Example and Bellman Verification

4.14.1 5×5 Gridworld Setup & Exceptional Dynamics

Consider the classic 5×5 Gridworld benchmark (Sutton & Barto Example 3.5). The grid cells represent states . At each cell, four actions are available: .

  • Equiprobable random policy: for all four directions in every state.
  • Discount factor: .
  • Ordinary moves: Stepping within the grid yields reward .
  • Off-grid moves: Actions that would push the agent off the grid leave the agent in its current location and yield reward .
  • Special State A (row 1, col 2): Any action yields immediate reward and transports the agent to state (row 5, col 2).
  • Special State B (row 1, col 4): Any action yields immediate reward and transports the agent to state (row 3, col 4).

4.14.2 Worked Verification 1: Ordinary Interior Cell (3, 3)

Worked Example — Bellman Verification for Cell (3, 3):

The displayed value for cell (3, 3) is . Its four neighboring cell values in the grid are:

  • Up (2, 3):
  • Right (3, 4):
  • Down (4, 3):
  • Left (3, 2):

Applying the Bellman expectation equation with , , and :

The Bellman expectation calculation perfectly matches the displayed grid value!

4.14.3 Worked Verification 2: Special State A (1, 2)

Worked Example — Bellman Verification for Special State A:

From state , every action yields reward and moves to (row 5, col 2), whose displayed value is . The displayed value of is .

Intuition: Why is even though immediate reward is ? Because state teleports the agent to near the bottom edge where random movement frequently hits the boundary, incurring negative rewards.

4.14.4 Worked Verification 3: Special State B (1, 4)

Worked Example — Bellman Verification for Special State B:

From state , every action yields reward and moves to (row 3, col 4), whose displayed value is . The value of is:

4.15 Optimal Policies and Bellman Optimality Equations

4.15.1 Partial Ordering and Definition of Optimal Policy

Value functions define a partial ordering over policies. A policy is defined to be better than or equal to a policy if its expected return is greater than or equal to that of in all states:

An optimal policy is a policy that is better than or equal to all other policies in every state. There is always at least one optimal policy. All optimal policies share the same optimal value functions, denoted and .

4.15.2 Optimal Value Functions and

The optimal state-value function is the maximum state value achievable under any policy:

The optimal action-value function is the maximum action value achievable under any policy:

4.15.3 Bellman Optimality Equation for

The Bellman optimality equation for replaces policy averaging with action maximization:

This equation states that under an optimal policy, the value of a state must equal the expected return from the single best action available in that state.

Backup Diagram for :

The backup diagram for is identical to , except the policy branching arc is replaced by an arc labeled "max" over the actions, signaling that the agent greedily chooses the single best action choice.

4.15.4 Bellman Optimality Equation for

The Bellman optimality equation for is:

4.15.5 Greedy Policy Improvement & One-Step Lookahead

If you know and the environment dynamics , an optimal policy can be determined via one-step lookahead:

Key Insight: If you know , selecting the optimal action does NOT require knowing the environment dynamics ! You simply pick . This is why model-free RL algorithms (like Q-learning) estimate directly.

4.16 Optimality and Approximation

4.16.1 Tabular Solvability vs Real-World Complexity

For small finite MDPs, the Bellman expectation equations form a set of linear equations that can be solved directly using linear algebra or iterative dynamic programming. The Bellman optimality equations form a non-linear system (due to the operator) that can be solved via Dynamic Programming (Value Iteration or Policy Iteration).

However, exact solution requires three conditions:

  1. Accurate model dynamics must be known.
  2. Sufficient computational power to solve the system of equations.
  3. Memory to store values for all states (Markov property).

4.16.2 Bridge to Approximate Methods and Deep RL

In realistic applications (Atari games, autonomous vehicles, traffic signal grids), the state space is continuous or astronomically large. Exact tabular solutions become impossible (curse of dimensionality). The goal shifts from exact tabular optimality to useful approximation using neural network function approximators and .

4.17 Summary

4.17.1 Framework Recap

In this lecture, we built the complete framework of a Markov Decision Process. The five core elements are:

  1. State () — what the agent perceives. The Markov property means the future depends only on the current state, not the history.
  2. Action () — what the agent can do.
  3. Model / Dynamics () — the transition probabilities and expected rewards .
  4. Reward () — the scalar signal. The reward hypothesis says all goals reduce to maximizing expected cumulative reward.
  5. Policy () — the behavior rule mapping states to actions.

We also derived state transition probabilities , expected rewards , conditional expected rewards , discounted return , Bellman expectation equations, and Bellman optimality equations.

4.17.2 Review of Key Terms

Term Short Definition
Finite MDPAn MDP with finite state , action , and reward sets.
State ()The information used at time step to make decisions and predict future outcomes.
Action ()The decision selected by the agent at time step .
Dynamics ()Probability of next state and reward given current state and action .
Transition Probability ()Probability of next state after action in state , marginalizing over rewards.
Expected Reward ()Average immediate reward expected after action in state .
Policy ()Probability of selecting action in state .
Return ()Total accumulated future reward from time step onward, discounted by .
Discount Factor ()Parameter in controlling the present value of future rewards.
State-Value Function ()Expected return starting from state and following policy .
Action-Value Function ()Expected return starting from state , taking action , then following policy .
Bellman EquationA self-consistency recursive equation relating a value to expected immediate reward and successor values.
Optimal Value Function ()The maximum achievable value function over all possible policies.
Backup DiagramGraphical tree representation showing how values back up from successor states/actions.

4.17.3 Looking Ahead to Dynamic Programming

Hook for next class: We have defined MDPs and Bellman equations. Next, we will learn how to solve MDPs using Dynamic Programming (Policy Evaluation, Policy Iteration, and Value Iteration) when the model dynamics are fully known!

4.18 Review Questions and Practice Problems

Question 1: Define a finite MDP. Explain why the finiteness of , , and is useful in tabular reinforcement learning.

Solution: A finite MDP is a Markov Decision Process where the state space , action space , and reward set all contain a finite number of elements. Finiteness ensures that the model dynamics , policies , and value functions / can be represented explicitly as lookup tables, and all expectations reduce to finite exact summations.

Question 2: Explain the agent-environment interface using the trajectory . Why is the reward following written as ?

Solution: At time step , the agent observes state and chooses action . The environment responds at discrete time step by transitioning to state and generating reward . The subscript emphasizes that reward is received after the action is executed and arrives together with the next state .

Question 3: State the Markov property in the context of an MDP. What must the state representation contain for this assumption to be reasonable?

Solution: The Markov property states that . To be Markov, the state representation must summarize all historical information required to predict future states and rewards without needing past history.

Question 4: Given the dynamics table below for state and action , compute , , and .

20.30
00.20
40.10
10.40

Solution:

Question 5: Compute the discounted return for the reward sequence 2, 0, 3, 5 with . Then compute it again with and interpret the difference.

Solution:

For with :

For : . When , the agent considers only the immediate reward and ignores all future consequences.

Question 6: A continuing traffic-control task gives reward equal to negative total vehicle delay every minute. Explain why discounting is useful, and mention one drawback of choosing too small.

Solution: In a continuing task, the horizon is infinite. Without discounting (), the cumulative sum of negative rewards would diverge to , making strategy comparisons impossible. Discounting with guarantees a finite return. However, choosing too small (e.g. ) makes the agent short-sighted (myopic) — it may clear a small queue immediately while causing catastrophic traffic gridlock five minutes later.

Question 7: Consider state with two actions. Action gives reward 2 and moves to (). Action gives reward 0 and moves to (). If , , and , which action is greedy with respect to these values? Show the one-step lookahead calculation.

Solution:

Calculate one-step lookahead expected return :

Since , action is greedy with respect to these value estimates.

Question 8: In the recycling robot example, identify the states, actions, rewards, and one stochastic transition. Why does the transition table define a finite MDP?

Solution: States: . Actions: . Rewards: . Stochastic transition: Searching from Low battery remains in Low with probability (reward ) and drops to High (rescuing) with probability (reward ). It is a finite MDP because state, action, and reward sets are all finite.

Question 9: For the recycling robot, suppose from state Low, action search gives reward and remains in Low with probability , but moves to High with probability with reward . If , , and , compute the one-step expected return for search from Low.

Solution:

Question 10: Formulate an Atari game as an MDP. Specify state representation, actions, rewards, terminal condition, and why function approximation becomes necessary.

Solution: State: stacked recent screen frames (e.g. 4 consecutive frames of 84×84 pixels) to capture velocity. Actions: discrete joystick buttons (up, down, left, right, fire). Reward: change in game score. Terminal condition: losing all lives or completing level. Function approximation is necessary because state space size () makes tabular storage impossible.

Question 11: Formulate a traffic signal control problem as a finite MDP after discretization. Clearly specify states, actions, rewards, and transition behavior.

Solution: State: discretized vehicle queue counts and waiting time brackets per lane. Actions: select next signal phase or extend current green light phase. Reward: negative sum of total vehicle delay across lanes. Transitions: governed by stochastic vehicle arrival and departure rates.

Question 12: Write the Bellman equation for and explain in words why it averages over both the policy and the environment dynamics.

Solution: . It averages over the policy because the agent stochastically picks actions, and averages over environment dynamics because the environment stochastically responds with a next state and reward.

Question 13: Derive the Bellman optimality equation for from the idea that the optimal value of a state is obtained by the best first action followed by optimal behavior.

Solution: The optimal value is the maximum expected return under any action choice. Taking action yields expected immediate reward plus discounted optimal return . Maximizing over all available actions gives .

Question 14: In the gridworld example, verify the Bellman relation for special state B using reward , , and the displayed value of B' ().

Solution: From B, all actions give reward and transport to B' with value . Bellman expectation: . The displayed value matches the expectation.

Question 15: Explain the difference between exact optimality and useful approximation. Why is approximation unavoidable in large MDPs such as video games or traffic networks?

Solution: Exact optimality computes the exact value function or policy for every state. Useful approximation estimates using parameterized function approximators like deep neural networks . Approximation is unavoidable in large MDPs because state spaces are far too large to store or compute in tabular memory.

Exam Guidance Summary

1. Exploration vs Exploitation: UCB (Upper Confidence Bound) and epsilon-greedy are the two standard strategies. UCB balances exploration by adding a confidence bonus to less-visited actions. Epsilon-greedy takes a random action with probability .

2. Policy subscript matters: Always write as a subscript on value functions: and . Never write or without the policy.

3. Model dynamics, Bellman equations, and value functions: Master the master dynamics , transition probabilities , expected rewards and , discounted return recursion , and Bellman expectation/optimality equations for .

4. Tabular Gridworld Verification: Practice numerical Bellman expectation verifications for ordinary cells () and jump states (, ).

5. Episodic vs Continuous tasks and terminal convention: Episodic tasks end in a terminal state where and can be used. Continuous tasks run indefinitely and require .

Key Industry Applications

The MDP framework is not just theory. It underlies a wide range of real-world systems:

  • Autonomous driving: States are sensor readings (camera, lidar); actions are steering, acceleration, braking; rewards reflect safety, progress, and comfort.
  • Portfolio management: States are market conditions; actions are buy/sell/hold; rewards are profit (or risk-adjusted return).
  • RoboCup soccer: Robots learn to play soccer by treating each game as an MDP with states (positions, ball location), actions (move, kick), and rewards (goals scored).
  • Recommendation systems: States are user context; actions are which item to show next; rewards are engagement (clicks, watch time).
  • Video games: Atari-style games (the example from 4.8.1) where states are screen frames, actions are joystick moves, and rewards are score.
  • Traffic signal control: The example from 4.8.2 — states are queue lengths, actions are signal phases, rewards are negative delay.
  • Recycling robots: The textbook example from 4.8.3 — states are battery levels, actions are search/wait/recharge, rewards are cans collected.
  • Nuclear reactor control: A continuous task — states are reactor readings, actions are control adjustments, rewards reflect stability and safety. Runs indefinitely.
  • Cart-pole balancing: The classic control benchmark from 4.10.2 — states are pole angle and cart position, actions are left/right force, rewards reflect balance.

DRL Lecture 4 Notes · Markov Decision Processes

Deep Reinforcement Learning· postgraduate· 2026-07-18

Sections Breakdown

1Recap and Transition to Full Reinforcement Learning

From multi-armed bandits to full RL with states; the agent-environment interaction loop.

2Course Roadmap

The next three classes: MDP, solving MDPs, and dynamic programming.

3The Markov Property

Definition, intuition, and testing whether a state representation is Markov.

4Grid World Example

A noisy grid world with pits, terminal states, and step penalties.

5The Elements of MDP

State space, action space, reward function, and model dynamics.

6Deriving Quantities from Model Dynamics

State transition probabilities, expected immediate reward, conditional expected reward, and Start-Stop numerical example.

7Finite vs Infinite MDP

Why we assume finite MDPs and where the assumption breaks down.

8Example MDP Formulations

Video games, traffic signals, and the recycling robot textbook example.

9Reward Hypothesis and Return

The reward hypothesis, simple and discounted return, and the recursive form.

10Episodic vs Continuous Tasks

Classifying tasks and the cart-pole balancing example.

11Policy

Definition, stochastic versus deterministic policies, and the value-policy link.

12Value Functions

State-value and action-value functions under a policy.

13Bellman Expectation Equations

Derivation and structure of Bellman expectation equations for v_pi and q_pi, with backup diagrams.

14Gridworld Example and Bellman Verification

5x5 gridworld setup, special states A and B, and exact numerical Bellman expectation calculations.

15Optimal Policies and Bellman Optimality Equations

Partial ordering of policies, optimal value functions v* and q*, Bellman optimality equations, and one-step lookahead.

16Optimality vs Approximation

Exact tabular solution vs function approximation in high-dimensional or continuous MDPs.

17Summary

Recap of the five MDP elements, table of key terms, and a look ahead to solving MDPs.

18Review Questions and Practice Problems

Complete 15 worked review questions covering all aspects of finite MDPs.

Postgraduate students in Deep Reinforcement Learning

Exam Revision Notes

Below is the distilled, exam-ready core of this lecture. Every entry is built from the full textbook notes above. Use this section for rapid review — but if something doesn't make sense, go back to the full explanation in the main content.

Markov Property

Must-know: A state is Markov if it is a sufficient summary of the past: knowing the full history adds nothing about the next state beyond the current state. The property is about the state representation, not the problem.

⚠️ Top pitfall: Thinking the Markov property is a property of the problem. If your state omits needed information (e.g. battery level), the property fails — you must enrich the state.

Self-check: If two agents are in the same board position but reached it by different move sequences, can a Markov state still make the right decision? Why?

Connects to: Elements of MDP, Model Dynamics, State Space.

MDP Elements

Must-know: An MDP is specified by states, actions, model dynamics (transition probabilities and rewards), and the reward function. The policy is the fifth element you want to learn.

⚠️ Top pitfall: Forgetting that the reward function signals what the goal is, not how to achieve it. Rewarding sub-goals can train a misbehaving agent.

Self-check: Name the four elements you must pin down to model a problem as an MDP, and the fifth you learn.

Connects to: Model Dynamics, Reward Hypothesis, Finite vs Infinite MDP.

Model Dynamics & Derivations

Must-know: The model dynamics is the master table of the environment. From it you derive state transition probabilities , expected immediate rewards , and conditional rewards . Probabilities from any must sum to 1.

⚠️ Top pitfall: Confusing the joint with the marginal . Sum over rewards to get the transition probability.

Self-check: Given and , what is ?

Connects to: State Transition Probabilities, Expected Immediate Reward, Conditional Rewards.

Return (Discounted) & Recursion

Must-know: The return is the discounted sum of future rewards starting from time . The recursive relation expresses current return in terms of next step's return.

⚠️ Top pitfall: Forgetting that starts at , not , or using for an infinite continuous task.

Self-check: With and rewards over , compute by working backwards.

Connects to: Episodic vs Continuous, Policy, Value Functions.

Bellman Expectation Equations

Must-know: The Bellman expectation equation relates the value of a state (or state-action pair) to the expected reward and discounted values of successor states under a given policy .

⚠️ Top pitfall: Forgetting that averages over BOTH the policy (action choice) and environment dynamics (next state and reward).

Self-check: Write the relationship between and .

Connects to: State-Value Function, Action-Value Function, Backup Diagrams.

Gridworld Bellman Verification

Must-know: In tabular gridworlds, the Bellman expectation equation allows exact numeric verification of state values under equiprobable random policies by averaging neighboring cell values.

⚠️ Top pitfall: Forgetting off-grid penalties or failing to account for exceptional jump state dynamics.

Self-check: Why does special state A have a high value () even though its destination A' has a negative value ()?

Connects to: Bellman Expectation Equations, State-Value Function.

Bellman Optimality Equations

Must-know: The Bellman optimality equation replaces policy averaging with maximization over actions. The optimal value is the maximum expected return achievable by any policy from state .

⚠️ Top pitfall: Confusing Bellman expectation equations (linear, policy-dependent) with Bellman optimality equations (non-linear system due to the max operator).

Self-check: If is known for all actions, how do you pick the optimal action in state ?

Connects to: Optimal Policy, One-Step Lookahead, Action-Value Function.

Exact Optimality vs Approximation

Must-know: Bellman optimality equations can be solved exactly for small tabular MDPs, but large state spaces (e.g., Atari, traffic networks) require value function approximation and Deep RL.

⚠️ Top pitfall: Thinking exact DP solutions can be stored for continuous or combinatorial state spaces without neural network approximations.

Self-check: Why is exact tabular calculation impossible for traffic signal control with continuous waiting times?

Connects to: MDP Formulations, Deep Reinforcement Learning.

Was this lecture useful?

Loading comments…
🤖

BitsNotes AI Assistant

Subject Notes Assistant

Configure AI Chat

Choose how to access the chatbot
Have your own API key?

Switch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.

🔑 Enter API key above to fetch live models from provider, or enter model name manually.
OpenAI-Compatible API Support

Choose any provider preset (Gemini, DeepSeek, Kimi, GLM, MiniMax, Qwen, OpenAI, Groq, Ollama, etc.) or enter a custom endpoint URL.

Security & Privacy First

Your API key is sent directly from your browser to your specified provider. BitsNotes servers never store or see your key.