Unit 1 of 11 · about 3 hours · explain
Sequential decisions, contextual bandits and the agent-environment boundary
Supervised learning predicts a label for a fixed input. RL chooses actions that change what happens next. If the boundary is drawn in the wrong place, later values optimize the wrong loop.
You'll be able to
- Explain how supervised prediction, contextual bandits and full RL differ in whether actions change future situations.
- Draw the agent-environment loop and name what belongs to the agent and what belongs to the environment.
- Decide whether a new task is a bandit, a contextual bandit or a sequential MDP and state what information the policy may use.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Lecture 1 sequential decisions and agent-environment loopStanford CS234 Winter 2026 - Foundations and Planning
Sequential Decision Process: Agent and the World through Types of Sequential Decision Processes (slides 34 to 38 in the footer), with History (slide 35) and Markov Assumption (slide 36) for context
- Agent-environment interfaceReinforcement Learning: An Introduction (2nd ed.) - Chapters 3 and 4
Chapter 3, Section 3.1, The Agent-Environment Interface, Figure 3.1 and trajectory (3.1) with dynamics (3.2) and (3.3), printed pp. 47 to 49. The authors post the full text free at incompleteideas.net.
- Associative search as contextual banditsReinforcement Learning: An Introduction (2nd ed.) - Chapter 2 bandits
Chapter 2, Section 2.9, Associative Search (Contextual Bandits), with Exercise 2.10, printed p. 41. The authors post the full text free at incompleteideas.net.
- Two slot machines and three policiesHands-on Modern RL - MDPs, Values and Bellman Equations
Two Slot Machines and Three Policies, Three Outcomes with the 60 percent and 40 percent machines and expected rewards 0.2 and minus 0.2 (page read 2026-10-14)
Focus on
- Supervised learning uses fixed input-output pairs. RL uses trial and error with delayed consequences. Bandits remove state change to isolate exploration.
- The agent selects from . The environment returns and . Everything outside the agent is the environment.
- Contextual bandits add a context that selects the payoff table, but actions still affect only immediate reward. Full RL lets actions change the next situation.
Common mistakes · 3
- Treating a contextual bandit as full RL and adding discounting and bootstrapping where no next state exists.
- Drawing the boundary so the agent owns the reward function or the physics. The environment owns dynamics and reward. The agent owns the policy and value estimates.
- Assuming greedy action selection solves exploration. With 10 pulls each on 60 versus 40, about 0.128 of experiments rank the worse arm first, so exploitation inherits estimation error.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.When is a task a contextual bandit rather than full RL?Answer
When a context selects the payoff table but the action affects only immediate reward and not the next situation. Full RL lets actions change the next state.
2.Who owns what in Sutton Figure 3.1?Answer
The agent owns the policy and value estimates. The environment owns the dynamics and the reward. State and reward pass from environment to agent. Action passes back.
3.What are the expected totals for uniform random and always-A over 100 rounds on the 60 versus 40 machines?Answer
Uniform random gives 0 per round and 0 in total. Always-A gives 0.2 per round and 20 in total.
4.Why can 10 pulls each still pick the worse machine?Answer
Small-sample noise can reverse the order. About 0.128 of experiments give more wins to B than to A, so committing to the observed winner locks in the mistake.
Practice
- Sutton and Barto Exercises 3.1 to 3.3: MDP framing drills
Exercises 3.1, 3.2 and 3.3, printed p. 51; write three tasks, test MDP adequacy and action-definition effects
Do on paper before the formulation unit. Keep one example where the Markov state is debatable. The authors post the full text free at incompleteideas.net.
You're done when
You draw the loop from memory, classify three new tasks as bandit, contextual bandit or MDP, and compute the two expected totals without notes.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 3 more in the section
- Stanford CS234 Winter 2026 - Foundations and PlanningStanford University · primary
Study Lecture 1 (
lecture1pre.pdfandlecture1post.pdf) and Lecture 2 on tabular MDP planning (lecture2pre.pdfandlecture2post.pdfunder https://web.stanford.edu/class/cs234/slides/). Work Assignment 1 independently: the written MDP, horizon and Bellman-operator questions and thevi_and_pi.pyplanning code on RiverSwim (NumPy only). Do not copy or publish course solutions. - Reinforcement Learning: An Introduction (2nd ed.) - Chapters 3 and 4Richard Sutton and Andrew Barto · required
The authors post the full second edition free at incompleteideas.net; cite the printed page numbers. Study Chapter 3 (Sections 3.1 to 3.7, finite MDPs, returns, Bellman equations and optimality) and Chapter 4 (Sections 4.1 to 4.7, policy evaluation, improvement, policy and value iteration, asynchronous DP and GPI). Reproduce Example 4.1 and Figure 4.1 exactly, then Example 4.3 (the gambler), and write exact tests for stochastic transitions, terminals, ties and stopping error.
- Hands-on Modern RL - MDPs, Values and Bellman EquationsWalking Labs · support
Use the value and Bellman page and the value experiment page (
code/chapter03_mdp/bellman_equation_verify.pyandgridworld_q_learning.pyrun on CPU in seconds) as a code companion. Check every equation against Sutton and Barto before adopting it. Pin commit 9231bab of walkinglabs/hands-on-modern-rl; itscode/chapterNNfolders do not follow the site chapter numbers. - Reinforcement Learning: An Introduction (2nd ed.) - Chapter 2 banditsRichard Sutton and Andrew Barto · reference
Read Section 2.9, Associative Search (Contextual Bandits), printed p. 41, with Exercise 2.10 as the context versus no-context check. Use only this section from Chapter 2.
Also in this section
- Gymnasium - Time Limits and Episode SemanticsFarama Foundation · required
Read the termination, truncation and "importance in learning code" sections, then the vector autoreset note at https://farama.org/Vector-Autoreset-Mode (next-step autoreset is the default in Gymnasium 1.x). Build a wrapper test that distinguishes termination from truncation and proves which cases bootstrap before using any third-party environment.
- Deep-ML - Planning ProblemsDeep-ML · support
Use named problems as closed-book checks after your own implementation passes: 157 (Bellman equation for value iteration), 164 (the gambler's problem by value iteration) and 467 (policy iteration). Read each problem's tests before trusting its statement.
- Reinforcement Learning Control Laboratory - Planning CoreRoadmap-Final · required
Complete Milestone A planning requirements: an explicit finite MDP, exact policy evaluation, value iteration, policy iteration, simulator agreement and seeded reward, transition, terminal and tie defects.