Module 22

Reinforcement Learning and Decision Theory

How can a system learn to make optimal decisions by interacting with an environment and experiencing the consequences of its actions?

lessons
37
duration
66 h 30 min
concepts
232
available in English
37 / 37
completed by you
0 of 37

Where it fits

Overview

Build the theory of sequential decision-making from expected utility and bandits (UCB, Thompson sampling, contextual and adversarial bandits) through MDPs, dynamic programming, and tabular RL (Monte Carlo, TD, SARSA, and Q-learning), then take it into deep RL: DQN and Rainbow, distributional RL, policy gradients, actor-critic, TRPO, PPO, DDPG, TD3, and SAC with Gymnasium and MuJoCo locally. A complete sequence covers AlphaGo, AlphaZero, and MuZero, including MCTS with policy and value networks, self-play, learned models, and their successors, in both theory and implementation. The module also covers optimal control (LQR, iLQR, MPC), model-based RL and world models, POMDPs, exploration, offline RL, game theory and multi-agent RL, sample-complexity theory, and current research. Each algorithm is derived, implemented from scratch in NumPy in the browser or PyTorch on the RTX 4060, and compared with reference implementations using rigorous statistical evaluation.

Why it matters

This module lets you build AlphaZero and MuZero, understand and debug the PPO used in RLHF and LLM reinforcement learning with verifiable rewards (m20, m23), and train control policies for robots (m24). It also provides the language of decision-making under uncertainty used in quantitative finance (Kelly, optimal stopping, and execution), security (adaptive attackers and prioritization with partial information), and adaptive experimentation. Afterward, you can read RL papers critically, reproduce their results at local scale, and distinguish real improvements from artifacts of seeds and implementation details.

Lessons 37

  1. 01Deciding under uncertainty: expected utility and the value of informationBefore learning, formulate a decision: expected utility, risk, Bayesian decisions, and information value. Solve decision trees and connect a single choice to the agent–environment loop.Core90 min
  2. 02The exploration-exploitation dilemma: stochastic bandits and UCBMulti-armed bandits isolate exploration versus exploitation. Define regret, analyze ε-greedy and explore-then-commit, derive UCB1 from Hoeffding, and compare policies across replicates.Core105 min
  3. 03Lower bounds, KL-UCB and Thompson samplingStudy minimax and Lai–Robbins lower bounds, KL-UCB, Thompson sampling, Gittins indices, and pure exploration for best-arm identification.Advanced110 min
  4. 04Contextual bandits: LinUCB, linear Thompson sampling and off-policy evaluationContextual bandits learn policies whose best action varies with context. Derive LinUCB and elliptical potential, examine linear Thompson sampling, and evaluate logged policies using DM, IPS, SNIPS, and doubly robust estimation.Core110 min
  5. 05Adversarial bandits and learning with experts: Hedge and EXP3Study adversarial bandits and expert advice through Hedge, EXP3, entropy-regularized optimization, and non-stationary environments.Advanced100 min
  6. 06Markov decision processes: policies, returns and Bellman equationsModel sequential decisions as Markov decision processes and evaluate stationary policies using discounted returns and Bellman equations.Core105 min
  7. 07Bellman optimality and value iterationDerive Bellman optimality, value iteration and policy-loss bounds, then solve finite-horizon decisions by backward induction.Core105 min
  8. 08Policy iteration, linear programming and occupancy measuresStudy policy improvement and iteration, linear programming, discounted occupancy and constrained Markov decision processes.Core100 min
  9. 09Monte Carlo learning: evaluation and control by averaging episodesEstimate and control episodic returns using Monte Carlo methods, first and every visit, and off-policy importance sampling.Core100 min
  10. 10Temporal-difference learning: TD(0), n-step and TD(λ)Learn temporal-difference prediction, multi-step returns, eligibility traces and batch certainty equivalence.Core115 min
  11. 11Temporal-difference control: SARSA, Q-learning and maximization biasApply temporal-difference control with SARSA, Q-learning, Expected SARSA, and double Q-learning, and compare their behavior and convergence assumptions. GPUCore105 min
  12. 12Value function approximation and the deadly triadStudy value-function approximation, projected Bellman equations, LSTD and the deadly triad, including gradient TD and fitted Q iteration.Advanced110 min
  13. 13Real environments: Gymnasium, MuJoCo and the engineering of the interaction loopBuild reliable reinforcement-learning environment loops with Gymnasium, vector resets, wrappers, probes and MuJoCo. GPUCore100 min
  14. 14Deep Q-Networks: replay, target networks and AtariThe jump from table to pixels: DQN as online fitted Q iteration with convolutional networks, stabilized by replay and a target network. Analyze what each component addresses in the deadly triad, correct overestimation with Double DQN, and attend to engineering that determines results (efficient buffer, Huber loss, ε schedule, evaluation protocol). Implement from scratch and train on the RTX 4060. GPUCore115 min
  15. 15Beyond DQN: dueling, prioritized replay, multi-step, noisy nets and RainbowSix independent ideas improving DQN and their combination in Rainbow, with attention to ablation evidence. Implement dueling, prioritized replay with a sum tree, n-step targets with off-policy corrections (Retrace and V-trace), and noisy nets; review data efficiency in Atari 100k (DER, SPR, BBF) and its battle against loss of plasticity. GPUAdvanced105 min
  16. 16Distributional RL: learning the return distributionLearn the full return distribution rather than only expected value. Study the distributional Bellman operator and its Wasserstein contraction, categorical (C51), quantile (QR-DQN) and implicit (IQN) representations, risk-sensitive policies with CVaR, and the now-central large-network idea of learning values as classification (two-hot, HL-Gauss), also used in MuZero and DreamerV3. GPUAdvanced100 min
  17. 17The policy gradient theorem and REINFORCEChange approach: instead of learning values and acting greedily, directly optimize a parametrized policy. Prove the policy gradient theorem, derive REINFORCE and its autograd surrogate-loss implementation, and reduce variance with causality and baselines, including the optimal baseline. Clarify which gradient common implementations actually compute. GPUCore110 min
  18. 18Actor-critic, advantages and generalized advantage estimationJoin the two families: a TD-trained critic gives the actor advantage estimates with lower variance than returns. Derive GAE as a λ-return of TD errors with distinct roles for γ and λ, build A2C with vectorized environments, and handle implementation details: truncation bootstrapping, mid-rollout resets, entropy and shared heads. GPUCore110 min
  19. 19Monotonic improvement: performance difference, natural gradient and TRPOAn overly large gradient step destroys the policy and future data. Prove the performance difference lemma, construct the surrogate objective and monotonic-improvement bound, derive natural policy gradient using Fisher geometry, and implement TRPO with conjugate gradients and line search. Close with modern global convergence theory for policy-gradient methods. GPUAdvanced115 min
  20. 20Proximal Policy Optimization: the algorithm and its detailsLocate PPO on the map: from TRPO's surrogate to the clipped objective, its case-by-case analysis and the adaptive KL-penalty variant. Implement the full CleanRL-style loop, study implementation details behind much of its performance, and diagnose training using approximate KL, clipped fraction and explained variance. Train locally in MuJoCo and prepare for RLHF and MAPPO. GPUCore120 min
  21. 21Making deep RL work: debugging, statistical evaluation and reproducibilityApply incremental RL debugging, account for seed variance, compare robust aggregate metrics, tune fairly and detect reward specification gaming. GPUCore90 min
  22. 22Off-policy continuous control: deterministic policy gradient, DDPG and TD3Derive the deterministic policy gradient, build DDPG and TD3, and examine critic errors and their corrections in continuous-action control. GPUCore105 min
  23. 23Maximum entropy RL and Soft Actor-CriticDerive soft Bellman equations and Boltzmann policies, build SAC with tanh-squashed Gaussian actions and automatic temperature, and interpret control as inference. GPUAdvanced110 min
  24. 24Optimal control theory: LQR, LQG, iLQR and model predictive controlDerive LQR and Riccati recursion, combine control with Kalman estimation in LQG, and study iLQR, MPC, HJB and Pontryagin. GPUAdvanced115 min
  25. 25Model-based RL: Dyna, probabilistic ensembles and planning with learned modelsStudy model-based RL through Dyna, uncertain dynamics ensembles, PETS planning, MBPO branched rollouts and value equivalence. GPUAdvanced110 min
  26. 26Latent world models: World Models, PlaNet and DreamerStudy latent world models from World Models and PlaNet to Dreamer, DreamerV3 techniques, TD-MPC2 and transformer or diffusion alternatives. GPUAdvanced115 min
  27. 27AlphaGo and AlphaGo Zero: search as a policy improvement operatorFollow AlphaGo's combination of policy and value networks with MCTS and AlphaGo Zero's single residual network trained through self-play. Interpret network-guided search as policy improvement through visit targets, approximate policy iteration, expert iteration, and regularized optimization.Advanced110 min
  28. 28AlphaZero from scratch: self-play, batched MCTS and training on the local GPUBuild AlphaZero for Connect Four at local-machine scale: implement the game, training search, multiprocess actors and learner with batched RTX 4060 inference, a symmetry-augmented buffer, and Elo and perfect-solver evaluation. Examine realistic throughput budgets and debugging methods. GPUAdvanced120 min
  29. 29MuZero: planning with a learned modelStudy MuZero's latent model, which predicts rewards, values, and policies relevant to planning without requiring game rules. Implement representation, dynamics, and prediction functions, unrolled n-step targets, latent MCTS, min-max normalization, categorical value support, and Reanalyse on top of AlphaZero. GPUAdvanced120 min
  30. 30Frontier of the AlphaZero line: Gumbel, sampled MCTS, EfficientZero and algorithm discoveryExamine developments after MuZero: MCTS as regularized optimization, Gumbel AlphaZero, Sampled MuZero, Stochastic MuZero, EfficientZero, and learned search for discovery in AlphaTensor, AlphaDev, and formal proof. Identify open questions and limitations in imperfect information. GPUResearch105 min
  31. 31Partial observability: POMDPs, belief states and policies with memoryFormalize partially observable decision problems, derive Bayesian belief updates and finite-horizon value functions, and compare exact, approximate, particle-based and recurrent approaches. GPUAdvanced110 min
  32. 32Exploration in deep RL: shaping, intrinsic rewards and posterior samplingWith sparse or misleading rewards, ε-greedy exploration can take exponential time. Study potential-based shaping and its invariance theorem, count bonuses and pseudo-counts, prediction-error curiosity and the noisy-TV trap, RND, deep exploration through posterior sampling (PSRL and bootstrapped DQN), and Go-Explore. Extend optimism and Thompson sampling from bandits to MDPs. GPUAdvanced105 min
  33. 33Offline RL: learning from fixed data without interactionStudy why naive off-policy learning fails on fixed logs, then compare policy constraints, conservative value regularization, IQL expectiles, sequential off-policy evaluation, and return-conditioned sequence models. GPUAdvanced110 min
  34. 34Game theory for learning agents: equilibria, dynamics and CFRStudy normal-form and Markov games, Nash and correlated equilibria, the minimax theorem, learning dynamics, and their relationship with equilibria. Extend to imperfect-information extensive-form games and counterfactual regret minimization in poker.Advanced115 min
  35. 35Deep multi-agent RL: cooperation, competition and leaguesApply game theory to deep multiagent RL: independent learners and nonstationarity, centralized training with decentralized execution, multiagent credit assignment, VDN, QMIX, MAPPO, and competitive self-play with populations, leagues, and PSRO. Practice locally with PettingZoo. GPUAdvanced110 min
  36. 36RL theory: sample complexity, regret in MDPs and function approximationStudy how much data decision learning requires: prove the simulation lemma, derive sample complexity with a generative model, examine PAC-MDP exploration and tabular episodic regret, and assess guarantees and limits under function approximation, coverage, and Bellman completeness.Research110 min
  37. 37Frontier: in-context RL, generalist agents, scaling and RL for language modelsMap active research using the module's tools: meta-RL and in-context RL, generalist agents and interactive world models, scaling deep RL, RL in language-model reasoning, and open-ended learning. Learn to read claims critically, replicate at small scale, and choose problems. GPUResearch100 min

Module capstone

Your own RL library and an end-to-end comparative study

Bring the agents built in this module together in a tested package with common interfaces, probe environments, and experiment logging: bandits, tabular agents, DQN with Rainbow improvements, PPO, SAC, TD3, AlphaZero with a Gumbel variant, and MuZero. Deliver two studies with the rigor of a research paper: (1) your own PPO, SAC, and TD3 against Stable-Baselines3 on three MuJoCo tasks with 10 seeds, IQM, performance profiles, and an ablation of implementation details; (2) AlphaZero and MuZero on Connect Four, trained on the RTX 4060, with an Elo curve, percentage of optimal moves against a solver, and the effect of the number of simulations. Conclude with a technical report documenting decisions, failures, and limits of the conclusions.

Check what you already know

  • Calculate the certainty equivalent of a lottery and the expected value of perfect information in a decision problem
  • Prove UCB1's logarithmic regret bound using Hoeffding's inequality
  • Implement beta-Bernoulli Thompson sampling and explain the Lai-Robbins bound
  • Implement LinUCB with rank-one updates and evaluate a policy using IPS and a doubly robust estimator
  • Derive Hedge's regret bound and explain why EXP3 needs randomization
  • Evaluate a policy exactly in a tabular MDP by solving (I − γP_π)V = r_π
  • Prove that the Bellman optimality operator is a contraction and bound the loss of the greedy policy
  • Formulate an MDP as a linear program and recover the policy from occupancy measures
  • Explain the difference between ordinary and weighted importance sampling in off-policy evaluation
  • Implement TD(λ) with eligibility traces and relate it to the λ-return
  • Explain maximization bias and correct it with double Q-learning
  • Explain the deadly triad using Baird's counterexample and the fixed point of linear TD
  • Distinguish terminated from truncated in Gymnasium and construct value targets correctly
  • Implement DQN with replay, a target network, and Double DQN in PyTorch
  • Implement prioritized replay with a sum tree and explain the Rainbow ablation
  • Implement C51's categorical projection and QR-DQN's quantile loss
  • Prove the policy gradient theorem and the unbiasedness of baselines
  • Implement GAE with termination and truncation masks in vectorized rollouts
  • Prove the performance difference lemma and explain the TRPO step using conjugate gradients
  • Implement PPO end to end and diagnose failures using approximate KL, clip fraction, and explained variance
  • Compare RL algorithms using IQM and stratified bootstrap intervals over seeds
  • Implement TD3 and explain its three corrections to DDPG
  • Derive the Boltzmann policy for maximum-entropy RL and implement SAC with the tanh correction
  • Derive the Riccati recursion for LQR and apply iLQR to a nonlinear system
  • Implement CEM planning with a probabilistic ensemble of dynamics models
  • Describe Dreamer's RSSM and learning in imagination
  • Explain why MCTS visit counts are a policy improvement target in AlphaGo Zero
  • Implement AlphaZero with batched MCTS and self-play for a small board game
  • Explain MuZero's unrolled training and min-max normalization in its search
  • Explain Gumbel AlphaZero and its policy improvement guarantee with few simulations
  • Update a belief state and explain the PWLC structure of a POMDP's value function
  • Prove that potential-based shaping preserves optimal policies and implement RND
  • Explain extrapolation error in offline RL and how CQL and IQL avoid it
  • Implement CFR in Kuhn poker and measure exploitability
  • Explain QMIX and the IGM condition and compare IPPO with MAPPO
  • State the simulation lemma and the idea behind UCBVI's regret bound

References