Core idea

An agent learns a policy from rewards. In an MDP an action can affect future states, so the objective is cumulative return rather than just the next reward.

The agent–environment loop

flowchart LR A["Agent"] -->|"action aₜ"| E["Environment"] E -->|"reward rₜ₊₁ and next state sₜ₊₁"| A

A policy chooses actions, a value function predicts returns, and a model predicts transitions and rewards. A method may use one or more of these components.

8.1 From immediate rewards to sequential decisions

An agent observes a state, takes an action, receives a reward, and observes a new state. A policy specifies how it selects actions. A value function estimates future return. A model describes how states and rewards change. Value-based methods estimate action values and derive a policy from them. Policy-gradient methods adjust the policy directly.

SettingDecision objectiveExample
Multi-armed banditChoose an arm with high immediate expected rewardSelect one of several ad variants
Contextual banditChoose an action for the current contextSelect an ad using page or audience features
Markov decision processMaximize cumulative reward when actions affect future statesNavigate a robot toward a goal

A bandit can update its estimate for action using , where includes the current observation. If the estimate was 4 after three pulls and the fourth reward is 8, the new estimate is 5. An -greedy policy chooses a random action with probability and a greedy action otherwise. UCB adds an exploration bonus, such as , after each arm has been tried. An optimal action under a known stationary reward model maximizes its expected reward. Exploration is necessary when those expectations must be learned.

PYQ — CT II 2022, Q7 (5 marks); 2021–22 semester, Q15

Original question scan — Class Test II 2022 Q7

Original question scan — 2021–22 semester Q15

Distinguish supervised learning and reinforcement learning, with an example. In supervised learning, each training example supplies a target label or value, such as an email labelled spam. In RL, an agent chooses actions and receives rewards; feedback may be delayed and actions can affect later states. A robot learns to navigate by receiving rewards for reaching a goal. RL also must balance exploration with exploitation.

8.2 Returns, values, and Bellman equations

An MDP specifies states, actions, a next-state and reward distribution, and a discount factor . Under the Markov property, the distribution of the next state and reward depends on the present state and action. The discounted return is . Set at a terminal time .

  • values a state under policy .
  • values a specified action followed by that policy.
  • For rewards 2 and 4 followed by termination at , the return before the first reward is .

Let denote the Bellman expectation operator. For a candidate value function ,

Policy evaluation solves . With bounded rewards and , contracts the sup-norm difference by at most . Repeated updates therefore converge to its unique fixed point. The optimal Bellman backup takes the maximum over actions outside the expectation.

Use at terminal states. The backup gives a new estimate using the current . Repeating the backup in value iteration approaches the optimal value function under the same discounted, bounded-reward assumptions.

Reading a Bellman equation

A Bellman equation splits the total return into immediate reward + discounted future value. The expectation averages over uncertain outcomes. The optimality equation replaces averaging over the policy’s action choices with a maximum over actions. It does not remove the expectation over the environment’s outcomes.

8.3 Dynamic programming, Monte Carlo, and TD

MethodWhere its target comes from
Policy iterationUse a known model to evaluate the policy, then improve it greedily
Value iterationUse a known model to repeatedly take the best Bellman backup, then extract a greedy policy
Monte CarloUse a sampled complete return after the episode
TD(0)Use a one-step sample and bootstrap from
Q-learningUse the greedy action-value target

For sampled prediction, both Monte Carlo and TD(0) use . The target in the table determines when the update can run and whether it depends on a current value estimate.

One value-iteration backup. From state S, action Stop pays 2 and terminates. Action Continue pays 1 and deterministically reaches a state currently valued at 4. At , the backup chooses .

One Q-learning update. If , reward is 1, the best next-state action value is 4, , and , then

The behavior policy can explore while the target uses a maximum. Set the continuation term to zero at termination.

Compare MC and TD on the same episode. Suppose the rewards are 1 then 4, with termination after the second reward. Let , , , and .

MethodTarget for Updated estimate
Monte Carlo after the episode
TD(0) after the first transition

Both move the estimate toward a target. MC uses the reward actually observed later. TD uses the current estimate of later rewards.

Off-policy Monte Carlo. A behavior policy generates episodes while a target policy is evaluated. Importance sampling reweights a return by the product of over the relevant actions. For ratios and , the trajectory weight is 2. The behavior policy must give positive probability to every action the target can choose in the evaluated trajectories.

8.4 Policy search, REINFORCE, and UCT

Policy search directly optimizes a parameterized policy. For the episodic objective of maximizing expected discounted return from the start state, the update contribution at step is . In REINFORCE, compute after the episode. A positive return weights the update in the direction that locally increases the sampled action’s log-probability. A state-dependent baseline can reduce variance.

UCT uses a UCB-style score at each tree node to balance exploiting a high mean rollout return with exploring a rarely visited child. Select children using that score, expand an unvisited child, simulate a continuation, and back up the sampled return along the path. For parent visits , child visits , and child mean , a common score is . Unvisited children are tried before applying the formula.

Policy, control, and convergence

Prediction estimates the value of a fixed policy; control seeks a better policy. A policy maps states to actions or action probabilities. A common control cycle estimates values and improves the policy toward actions with higher estimated returns while maintaining exploration. Model-based dynamic programming uses a known transition model; Q-learning learns from sampled transitions without one.

For finite MDPs, tabular Q-learning converges to optimal action values under standard assumptions including sufficient repeated exploration of state-action pairs, suitable diminishing step sizes, and discounted bounded rewards (or suitable episodic conditions). These guarantees do not automatically carry over to arbitrary neural function approximation, limited data or a changing environment.

PYQ — 2021–22 semester, Q14, Q17–18

Original question scan — 2021–22 semester Q14

Original question scan — 2021–22 semester Q17

Original question scan — 2021–22 semester Q18

Explain control policies, Q-learning and convergence; define an MDP and describe Monte Carlo. An MDP specifies states, actions, the distribution of the next state and reward given the current state and action, and a discount factor. A policy chooses actions. Q-learning updates towards and can explore with an -greedy behaviour policy. Under the conditions above its tabular estimates converge. Monte Carlo waits until an episode ends, calculates the sampled return from each visited state, and averages or incrementally updates value estimates toward those returns. A robot navigating a grid is a suitable example.

Method comparison and exam traps

MethodNeeds a transition model?Bootstrap?Needs episode end?
Dynamic programmingYesYesNo
Monte CarloNoNoYes, for complete returns
TD(0)NoYesNo
Q-learningNoYesNo
Terminal transitions

At a terminal next state, the continuation value is zero. Q-learning is off-policy because its target is greedy even if the behaviour policy explores.

Practice

  • 8A. Explain the difference between value iteration and policy iteration. For the two-action example, repeat the backup when the continuation state’s value drops from 4 to 1.
  • 8B. Update after reward 2 with , , and . Repeat with a terminal next state.
  • 8C. Compare a Monte Carlo target with a TD(0) target. Explain where UCT uses exploration and how it updates the tree.

Answer checks

ExerciseAnswer
8APolicy iteration alternates policy evaluation and improvement. Value iteration updates the value directly with a maximization. The new Continue score is , so choose Stop for value 2.
8BNonterminal target and updated value . Terminal target 2 and updated value .
8CMonte Carlo uses a completed return. TD(0) uses one reward and a bootstrap estimate. UCT uses an exploration bonus during child selection and backs up simulated return to visited ancestors.

References: Sutton and Barto, chapters 2–6 and 13 · Original UCT paper