29Reinforcement Learning and Statistical Learning Theory
Core idea: reinforcement learning is statistical learning with feedback. A policy controls which data are collected, and the learner must estimate long-run values from dependent, policy-dependent samples. Statistical learning theory gives the language for finite-sample guarantees: concentration inequalities, confidence sets, sample complexity, regret, optimism under uncertainty, and generalization.
29.1 Learning goals
After reading this chapter, students should be able to:
explain why reinforcement learning is statistically harder than supervised learning;
use concentration inequalities to construct confidence intervals for rewards and transition probabilities;
define sample complexity, PAC learning, and regret for sequential decision problems;
derive the upper-confidence-bound idea in multi-armed bandits;
explain optimism under uncertainty for finite MDPs;
connect model-estimation error to value-function error;
distinguish prediction error, control error, and exploration error;
describe why function approximation introduces generalization and distribution-shift challenges;
use simulation to study regret, confidence radii, and finite-sample error;
use AI tools responsibly to check assumptions behind statistical guarantees.
29.2 26.1 Why statistical learning theory is needed in RL
In dynamic programming, we assumed that the transition kernel and reward function were known:
Under that assumption, algorithms such as policy iteration and value iteration solve an optimization problem. In reinforcement learning, however, \(P\) and \(r\) are usually unknown. The agent observes samples
\[
(S_t,A_t,R_{t+1},S_{t+1}),
\]
and must learn from them.
This creates three statistical difficulties.
First, the samples are dependent. The state \(S_{t+1}\) is generated from \(S_t\) and \(A_t\), so observations are not iid.
Second, the data distribution is policy-dependent. If the agent changes its policy, it changes which states and actions will be observed.
Third, the goal is long-run control, not merely one-step prediction. A small error in transition estimation may be amplified by the planning horizon.
For a discounted problem, the effective horizon is approximately
Thus the statistical difficulty increases rapidly as \(\gamma\) approaches one.
Statistical viewpoint. Dynamic programming asks: if \(P\) and \(r\) are known, what is optimal? Statistical learning theory asks: if \(P\) and \(r\) are estimated from data, how many samples are needed to act nearly optimally with high probability?
29.3 26.2 From estimation to decision-making
Let \(\pi\) be a fixed policy. The value function satisfies
\[
V^\pi = r_\pi + \gamma P_\pi V^\pi,
\]
so
\[
V^\pi=(I-\gamma P_\pi)^{-1}r_\pi.
\]
If \(r_\pi\) and \(P_\pi\) are unknown, we may estimate them from data:
In supervised learning, the usual goal is prediction error. In RL, prediction error is only an intermediate quantity. The final question is whether the learned policy is good:
A basic finite-sample tool is the concentration inequality. Suppose \(X_1,\ldots,X_n\) are iid random variables with \(X_i\in[0,1]\) and mean \(\mu\). Let
The factor \(SA\) appears because we want the confidence statement to hold simultaneously over many state-action pairs. This is an example of a union bound.
Transition probabilities can be estimated by empirical frequencies:
where \(\varepsilon_P\) measures transition error. The factor \((1-\gamma)^{-2}\) explains why model estimation becomes difficult for long-horizon problems.
29.6.1 Interactive: model error amplification
The same one-step estimation error produces much larger value error when \(\gamma\) is close to one.
gamma=0.50, value error=0.0392, V=[0.646 1.877]
gamma=0.80, value error=0.1616, V=[2.455 4.273]
gamma=0.95, value error=0.6403, V=[13.075 15.463]
gamma=0.98, value error=1.5017, V=[34.968 37.516]
29.7 26.6 Multi-armed bandits as the simplest RL theory model
A multi-armed bandit is a one-state reinforcement learning problem. There are \(K\) actions. Each action \(a\) has an unknown mean reward
\[
\mu_a=E[R\mid A=a].
\]
The optimal action is
\[
a^*\in \arg\max_a \mu_a.
\]
At time \(t\), the learner chooses \(A_t\) and observes reward \(R_t\). The regret after \(T\) rounds is
The regret formula reveals the exploration-exploitation tradeoff. Pulling suboptimal arms creates regret, but without exploration the learner may never discover the best arm.
29.8 26.7 Upper confidence bounds
The upper-confidence-bound principle chooses actions according to optimistic estimates:
The first term exploits known high-reward actions. The second term explores uncertain actions.
This is called optimism under uncertainty. If an action has not been sampled much, its upper confidence bound may be large, so the agent tries it. If it turns out to be poor, the confidence interval shrinks and the action becomes less attractive.
29.8.1 Interactive: regret of exploration strategies
UCB explores using a shrinking confidence bonus. Constant-\(\epsilon\) exploration keeps exploring forever, which can lead to linear regret if \(\epsilon\) is not decayed.
import numpy as nprng = np.random.default_rng(2026)means = np.array([0.10, 0.20, 0.90, 0.40])K =len(means)T =2000def run_ucb(): counts = np.zeros(K) sums = np.zeros(K) rewards = []for t inrange(1, T +1):if t <= K: a = t -1else: avg = sums / np.maximum(counts, 1) bonus = np.sqrt(2* np.log(t) / np.maximum(counts, 1)) a =int(np.argmax(avg + bonus)) r = rng.binomial(1, means[a]) counts[a] +=1 sums[a] += r rewards.append(r)return np.array(rewards), countsdef run_epsilon_greedy(eps=0.1): counts = np.zeros(K) sums = np.zeros(K) rewards = []for t inrange(1, T +1):if rng.random() < eps or np.any(counts ==0): a = rng.integers(K)else: avg = sums / np.maximum(counts, 1) a =int(np.argmax(avg)) r = rng.binomial(1, means[a]) counts[a] +=1 sums[a] += r rewards.append(r)return np.array(rewards), countsucb_rewards, ucb_counts = run_ucb()eg_rewards, eg_counts = run_epsilon_greedy(0.1)opt_mean = means.max()ucb_regret = T * opt_mean - ucb_rewards.sum()eg_regret = T * opt_mean - eg_rewards.sum()print("UCB action counts:", ucb_counts.astype(int))print("epsilon-greedy action counts:", eg_counts.astype(int))print("UCB empirical regret:", round(ucb_regret, 2))print("epsilon-greedy empirical regret:", round(eg_regret, 2))
where \(\widetilde O\) hides logarithmic factors. Sublinear regret implies
\[
\frac{\operatorname{Regret}(T)}{T}\to 0.
\]
Thus the average loss per step vanishes.
29.10 26.9 PAC-MDP learning
PAC stands for probably approximately correct. In RL, a PAC-style statement usually has the following structure.
With probability at least \(1-\delta\), the learner takes more than \(N(\varepsilon,\delta)\) non-\(\varepsilon\)-optimal actions only finitely many times, where \(N(\varepsilon,\delta)\) is polynomial in relevant problem parameters.
A simplified goal is to learn a policy \(\widehat \pi\) such that
where the exponent \(c\) depends on the algorithm and theorem.
29.10.1 Interactive: sample complexity scaling
Even simplified bounds show strong dependence on \(\varepsilon\) and \(1-\gamma\). This helps explain why long-horizon RL is statistically difficult.
29.11 26.10 Optimism under uncertainty for MDPs
The bandit UCB idea extends to MDPs. Instead of choosing the action with the largest estimated reward, an optimistic planner chooses actions that are good in some plausible model.
Suppose the learner constructs a confidence set \(\mathcal{M}_t\) of MDP models consistent with the data:
\[
\mathcal{M}_t
=
\{M: M \text{ is statistically plausible at time } t\}.
\]
The policy \(\pi_t\) is optimal for the most favorable plausible model. If a poorly understood action might lead to high reward, optimism makes the agent explore it.
A common practical simplification adds an exploration bonus to the reward:
This equation is informal because the values live in different models, but it identifies the main sources of error:
transition and reward estimation error;
numerical planning error;
policy-induced distribution shift between the data and the learned policy.
29.12.1 Interactive: model estimation and value error
The plot shows a simplified relationship between transition-estimation error and value-function error for different discount factors.
import numpy as nprng = np.random.default_rng(5110)S =3A =2gamma =0.9P_true = np.array([ [[0.7, 0.3, 0.0], [0.2, 0.5, 0.3]], [[0.1, 0.7, 0.2], [0.0, 0.4, 0.6]], [[0.0, 0.1, 0.9], [0.0, 0.0, 1.0]],])r_true = np.array([ [0.2, 0.3], [0.1, 0.6], [1.0, 1.0],])def optimal_value(P, r, gamma, steps=500): V = np.zeros(P.shape[0])for _ inrange(steps): Q = r + gamma * np.einsum("sak,k->sa", P, V) V = Q.max(axis=1)return VV_true = optimal_value(P_true, r_true, gamma)for n in [10, 30, 100, 300, 1000]: P_hat = np.zeros_like(P_true)for s inrange(S):for a inrange(A): next_states = rng.choice(S, size=n, p=P_true[s, a]) counts = np.bincount(next_states, minlength=S) P_hat[s, a] = counts / n V_hat = optimal_value(P_hat, r_true, gamma) err = np.max(np.abs(V_hat - V_true)) transition_l1 = np.max(np.abs(P_hat - P_true).sum(axis=2))print(f"n per state-action={n:4d}, max transition L1={transition_l1:.3f}, value error={err:.3f}")
n per state-action= 10, max transition L1=0.200, value error=0.000
n per state-action= 30, max transition L1=0.333, value error=0.119
n per state-action= 100, max transition L1=0.120, value error=0.048
n per state-action= 300, max transition L1=0.100, value error=0.044
n per state-action=1000, max transition L1=0.066, value error=0.015
29.13 26.12 Distribution shift and coverage
In supervised learning, training and test data are often assumed to be drawn from the same distribution. In reinforcement learning, this assumption is fragile.
Let \(d^\pi(s,a)\) denote a state-action occupancy measure under policy \(\pi\). If data were collected by a behavior policy \(\pi_b\) but we evaluate or optimize a target policy \(\pi\), then a key quantity is the mismatch between
If \(d^\pi(s,a)>0\) but \(d^{\pi_b}(s,a)=0\), then the dataset contains no direct information about a state-action pair that the target policy may use. This is a coverage failure.
A common concentrability-style coefficient is
\[
C
=
\sup_{s,a}\frac{d^\pi(s,a)}{d^{\pi_b}(s,a)}.
\]
Large \(C\) indicates severe distribution shift.
This idea is especially important in offline reinforcement learning, which is studied in the next chapter.
29.14 26.13 Generalization with function approximation
Tabular theory often gives bounds depending on \(S\) and \(A\). With function approximation, the learner uses a class of value functions or policies:
\[
\mathcal{F}=\{f_\theta:\theta\in\Theta\}.
\]
The statistical question becomes: how large is the function class?
In supervised learning, complexity can be measured by VC dimension, covering numbers, Rademacher complexity, or norm-based neural-network measures. In RL, these ideas still matter, but the data distribution is policy-dependent and Bellman targets are bootstrapped.
For a value-function class \(\mathcal{F}\), a schematic generalization statement may have the form
the effective complexity often depends on feature dimension, norm constraints, covariance conditioning, and state-distribution coverage.
29.14.1 Interactive: approximation complexity and finite-sample error
Increasing model complexity can reduce approximation bias but increase estimation variance. This is familiar from supervised learning, but RL adds bootstrapping and distribution shift.
Explain why data collected by a reinforcement learning agent are usually not iid.
Give an example where a policy with high empirical reward may still be statistically uncertain.
Explain the difference between value-estimation error and policy suboptimality.
Why does the effective horizon \(1/(1-\gamma)\) appear in sample-complexity bounds?
Explain optimism under uncertainty in your own words.
Why is off-policy evaluation statistically difficult when coverage is poor?
29.18.2 Mathematical exercises
Use Hoeffding’s inequality to find \(n\) such that \(|\widehat \mu_n-\mu|\leq 0.05\) with probability at least \(0.99\).
Prove that if \(\|r-\widetilde r\|_\infty\leq \varepsilon_r\) and \(P\) is fixed, then \(\|V-\widetilde V\|_\infty\leq \varepsilon_r/(1-\gamma)\).
Derive the bandit regret identity \(\operatorname{Regret}(T)=\sum_a \Delta_a E[N_T(a)]\).
For a two-action bandit, compute the UCB index after the following observations: action 1 has \(10\) successes in \(20\) trials; action 2 has \(3\) successes in \(5\) trials; \(t=25\).
Let \(d^\pi\) and \(d^{\pi_b}\) be state-action distributions. Explain why a large ratio \(d^\pi(s,a)/d^{\pi_b}(s,a)\) increases variance in off-policy evaluation.
29.18.3 Computational exercises
Modify the UCB simulation to include Thompson sampling for Bernoulli rewards.
Compare regret curves for \(K=2\), \(K=5\), and \(K=20\) arms.
Simulate plug-in model estimation for a finite MDP and plot value error versus samples per state-action pair.
Study how value-estimation error changes as \(\gamma\) varies from \(0.5\) to \(0.99\).
Implement an optimistic value-iteration algorithm using reward bonuses.
Construct a behavior policy with poor coverage and show that off-policy value estimates become unstable.
29.18.4 AI-assisted exercises
Ask an AI assistant to explain the difference between PAC bounds and regret bounds. Then identify one important missing assumption in the response.
Give an AI assistant a short proof using Hoeffding’s inequality and ask it to check the union-bound step.
Ask an AI assistant to generate a counterexample where high empirical reward does not imply low uncertainty.
Ask an AI assistant to inspect UCB code and identify possible division-by-zero or initialization errors.
Ask an AI assistant to compare tabular sample-complexity bounds with function-approximation generalization bounds, then rewrite the explanation for a statistics audience.
29.19 Instructor notes
This chapter is intended to connect RL algorithms with finite-sample reasoning. For applied mathematics students, emphasize concentration inequalities, fixed-point perturbation, and regret. For statistics students, emphasize confidence sets, coverage, distribution shift, and the difference between prediction and control.
A useful classroom sequence is:
start with Hoeffding’s inequality;
apply it to bandit confidence intervals;
derive UCB as optimism;
show regret simulations;
explain why MDPs add transition estimation and horizon amplification;
close with function approximation and distribution shift.