Overview

6 Tabular Reinforcement Learning

The chapter presents tabular reinforcement learning as the practical bridge between temporal-difference theory and usable control algorithms. It explains that TD learning is foundational because it lets agents improve from experience without waiting for complete outcomes, using prediction error to update value estimates online. The discussion connects this idea to policy evaluation and improvement, shows why model-free learning is necessary in real settings, and introduces the core distinction between on-policy and off-policy methods as the basis for how agents learn from and act in uncertain environments.

To make the ideas concrete, the chapter develops a restaurant table-scheduling example where an agent must decide whether to take a guaranteed small reward or wait for a larger but uncertain one. This example is used to derive and validate TD updates, showing that repeated sampling can converge toward analytically optimal values even when transition probabilities are unknown. It then extends the same logic to action values with tabular Q-functions, emphasizing that tabular methods store one value per state or state-action pair and are therefore easy to interpret, update, and use for direct decision-making.

The later sections focus on the main tabular control algorithms: SARSA, Q-learning, and eligibility traces. SARSA learns on-policy from the action it actually takes, making it conservative and often safer under exploration risk, while Q-learning learns off-policy from the best possible next action and tends to be more optimistic and aggressive. Eligibility traces and TD(λ) are introduced as a way to spread credit backward over multiple steps, balancing bias and variance, with SARSA(λ) and Watkins’s Q(λ) showing how traces can be combined with on-policy or off-policy learning. The chapter closes with a gas-station inventory case study that demonstrates how these methods can solve a realistic sequential decision problem, highlighting that algorithm choice affects not just reward, but stability, safety, and business fit.

Like cooking, we use feedback from error to update parameters step by step.
The formula shows how each update moves the old value toward a better one.
Convergence behavior of Temporal difference learning algorithm.
illustration of problem of aligning within the TD framework
SARSA Algorithm Flowchart.
Q-learning Algorithm Flowchart.
Comparison of TD(0), Monte Carlo and TD(λ) methods.
Update mechanism of temporal difference learning with eligibility traces.
integrating eligibility trace in SARSA framework: SARSA(λ).
Integrating eligibility traces with Q-learning using Watkins's Q(λ) method.
Tabular Reinforcement Learning Curves and Performance Analysis.

Summary

  • In model-based learning, the agent has access to the full dynamics of the environment—the transition probabilities P(s'|s,a) and reward function R(s,a). Dynamic Programming is a model-based approach.
  • In model-free learning, the agent does not know these dynamics and must learn directly from experience tuples (s, a, r, s') gathered through trial and error. Temporal difference learning, Q-learning, and SARSA are all model-free.
  • In offline learning, the agent is trained on a fixed, pre-collected batch of data and does not learn during interaction.
  • In online learning, the agent updates its knowledge continuously during interaction with the environment, learning step-by-step as new experience arrives. All the temporal difference methods discussed in this chapter are online learners.
  • In on-policy learning, the agent learns to improve the same policy it is using to make decisions. It learns from its own "lived experience." SARSA is on-policy.
  • In off-policy learning, the agent can learn about a different policy (the target policy, typically the optimal one) than the one it is using to generate behavior (the behavior policy, typically an exploratory one). Q-learning is off-policy.
  • Temporal-Difference learning is one of the two pillars of reinforcement learning, enabling agents to learn from raw experience without a model of the environment.
  • The core idea of temporal difference learning is to update your predictions based on the error between your current guess and a slightly better guess one step into the future.
  • This process of updating estimates using other estimates is called bootstrapping, and it allows learning to happen online, after every single step.
  • The TD error (δ) is the learning signal, quantifying the "surprise" or difference between what you expected and what you observed.
  • Temporal difference learning is the bridge between Dynamic Programming (which needs a full model) and Monte Carlo methods (which must wait for an episode to end).
  • For an agent to make decisions in a model-free world, it must learn action values (Q(s,a)), not just state values (V(s)).
  • Tabular methods represent the value function as a lookup table or spreadsheet, with a distinct entry for every state-action pair.
  • Q-learning is the quintessential off-policy algorithm; it learns about the optimal greedy policy while behaving according to a different, more exploratory policy.
  • Because Q-learning uses the max Q-value for its update, it is considered optimistic and often converges faster to the optimal policy.
  • SARSA is the quintessential on-policy algorithm; it learns about the same policy it is using to make decisions, including all its exploratory actions.
  • Because SARSA's updates use the Q-value of the actual next action taken, it is considered more realistic or conservative, learning a policy that is robust in the face of its own exploration.
  • The credit assignment problem asks how to distribute credit for a reward among the many actions that may have led to it, especially when rewards are delayed.
  • Eligibility traces (TD(λ)) are the solution, creating a short-term memory that allows the TD error to be propagated backward to all recently visited state-action pairs.
  • The λ parameter controls how far back credit is assigned, providing a tuneable spectrum between one-step TD (λ=0) and Monte Carlo (λ=1).
  • SARSA(λ) is a highly effective on-policy algorithm that combines the stability of SARSA with the learning speed of eligibility traces.
  • Watkins's Q(λ) adapts traces for off-policy learning by resetting the traces to zero whenever a non-greedy (exploratory) action is taken.

FAQ

What is temporal-difference (TD) learning in reinforcement learning?Temporal-difference learning is a method where an agent updates its value estimates from experience step by step, without waiting for the end of an episode. It uses the difference between a predicted value and a bootstrapped target based on the next state to improve learning online.
Why is TD learning considered so important in reinforcement learning?TD learning is important because it bridges dynamic programming and Monte Carlo methods. It enables online learning, works with incomplete episodes, and forms the basis for many core RL algorithms such as SARSA, Q-learning, and TD(λ).
What is the TD error and how is it used?The TD error is the gap between the target and the current estimate. For state values, it is typically the difference between observed reward plus discounted next-state value and the current value estimate. The agent uses this error to adjust its value function toward better predictions.
What is the difference between on-policy and off-policy learning?On-policy learning learns about the same policy the agent is actually following, including its exploratory actions. Off-policy learning learns about a target policy that may be different from the behavior policy used to collect experience, allowing the agent to explore while learning a more optimal policy.
How does SARSA differ from Q-learning?SARSA is on-policy and updates using the action the agent actually takes next, so it learns from real behavior. Q-learning is off-policy and updates using the maximum next-state action value, so it learns the value of the greedy optimal policy regardless of the behavior policy.
What does “tabular” mean in tabular reinforcement learning?Tabular RL means storing values in a lookup table, such as a Q-table, where each state or state-action pair has its own entry. This works well when the state space is small enough to be represented explicitly.
Why do we need action values Q(s, a) instead of only state values V(s)?State values tell us how good a state is, but not which action to take. Action values are needed for control because they directly compare the expected return of each possible action in a given state.
What are eligibility traces and what problem do they solve?Eligibility traces are short-term memory variables that assign credit backward through time to recently visited states or state-action pairs. They solve the credit assignment problem by helping the agent distribute learning signals over multiple prior decisions instead of only the most recent one.
How do SARSA(λ) and Q(λ) use eligibility traces differently?SARSA(λ) is on-policy and uses eligibility traces to propagate credit based on the actual next action taken. Q(λ) is off-policy and uses the greedy next action, but Watkins’s version resets traces when a non-greedy action is taken to preserve the off-policy nature of Q-learning.
What is the main practical lesson from the gas station inventory example?The gas station example shows that tabular RL can learn effective business policies from experience alone. It demonstrates how SARSA, Q-learning, and eligibility traces can optimize inventory decisions by balancing profit, stockout risk, holding costs, and delayed delivery uncertainty.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Applied Reinforcement Learning ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Applied Reinforcement Learning ebook for free