4.1 Bandits, MDPs, and planning
This part of Reinforcement Learning develops the mechanisms below. Work the numerical examples or trace the code before checking the answer.
Concepts from other sections (3)
This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.
- Bellman equation: the recursive relation expressing a state’s value as immediate reward plus discounted next-state value. Read more: 4.4 World models, multiple agents, and RLHF
- Value function: the expected discounted return from a state (or state-action pair) under a policy. Read more: 4.4 World models, multiple agents, and RLHF
- Dynamic programming (DP): solving a problem by breaking it into overlapping subproblems and storing each subproblem’s answer the first time it is computed, which turns an exponential recursion into a polynomial computation. Read more: Chapter 9: Dynamic programming in Programming and Algorithms
Learning objectives
- Distinguish immediate reward optimization from sequential credit assignment.
Multi-armed bandits
Section titled “Multi-armed bandits”Reading: Sutton and Barto Chapter 2.
A bandit is RL with the state transitions removed: you repeatedly choose one of several actions (arms), each with an unknown reward distribution, and try to maximize total reward. That makes it the cleanest place to study exploration. Should you exploit the arm with the best estimated value, or explore another arm that might be better?
The simplest strategy is epsilon-greedy: with probability pick an arm uniformly at random, and otherwise pick the best-known one. Upper Confidence Bound (UCB) replaces randomness with optimism in the face of uncertainty, choosing the action that maximizes
where is how often arm has been tried and is the total number of steps; rarely tried arms get a large bonus. Thompson sampling keeps a posterior distribution over each arm’s value, samples from each, and plays the arm whose sample is highest, which balances exploration naturally because uncertain arms sometimes produce high samples.
Markov decision processes
Section titled “Markov decision processes”Reading: Sutton and Barto Chapter 3.
Adding state turns a bandit into a Markov decision process (MDP), the tuple : states, actions, transition dynamics , a reward function, and a discount factor . The agent’s behavior is a policy , a mapping from states to action probabilities.
To compare policies, define the value function, the expected discounted return from state when following :
and the Q-function, which also fixes the first action:
The central result is the Bellman equation, which says that the value of a state is the immediate reward plus the discounted value of the next state, averaged over the policy and the dynamics:
Every method in the rest of the chapter is, in one way or another, a way of solving or approximating this equation.
Dynamic programming
Section titled “Dynamic programming”Reading: Sutton and Barto Chapter 4.
If you know the MDP completely, you can solve the Bellman equation by iteration. Policy evaluation applies the Bellman equation repeatedly as an update until converges. Policy improvement makes the policy greedy with respect to the current value function. Policy iteration alternates the two until the policy stops changing, and value iteration fuses them into a single update that converges to the optimal value function .
The limitation is the premise: dynamic programming requires complete knowledge of the transition dynamics, and real-world problems rarely provide it. The next two methods learn from experience instead.
Summary
Section titled “Summary”Distinguish immediate reward optimization from sequential credit assignment. State the assumptions before applying the result to a different workload.
Review questions
Section titled “Review questions”-
Why can the greedy action have a lower return?
Answer
It can sacrifice future rewards or prevent useful exploration.
Chapter contents · Next: On-policy, off-policy, and value learning