Advanced Mathematics

Reinforcement Learning

Learning what to do from rewards alone: an agent acts, sees rewards, and improves its policy to maximise discounted future reward.

Needs a step first: 24

An agent in a state chooses an action, receives a reward and moves to a new state, as in a Markov chain whose steps it can steer, aiming for the most total reward with future rewards discounted by a factor γ\gamma per step. The value of a state satisfies the Bellman equation V(s)=max⁡a[r(s,a)+γV(s′)]V(s) = \max_a\big[r(s, a) + \gamma V(s')\big]: the best now is the best immediate reward plus the discounted best from where you land. Q-learning estimates these values from experience, while policy-gradient methods, used to train game-playing programs and to tune language models towards answers people prefer, adjust a network's action probabilities by gradient ascent.

Where it shows up: The Bellman equation is dynamic programming, which also runs route planners and the control of robots and machines.

How to hold it: In your head

See the Bellman equation as "the best from here is the best reward now plus the discounted best from where you land", and how the discount γ\gamma trades patience against haste.

What knowing it looks like

  • Solve the Bellman equation for a small deterministic problem and read off the best policy.
  • Explain how the discount factor changes which policy is best.
  • Carry out one Q-learning update by hand.

Test yourself

From state A an agent can "stay" (reward 1, remain in A) or "go" (reward 0, move to B). From B the only action gives reward 10 and ends the episode. Find the optimal value V∗(A)V^*(A) and the best action in A when γ=0.9\gamma = 0.9, and again when γ=0.5\gamma = 0.5.
Show the worked answer
V∗(B)=10V^*(B) = 10. Bellman: V∗(A)=max⁡(1+γV∗(A), 0+10γ)V^*(A) = \max\big(1 + \gamma V^*(A),\ 0 + 10\gamma\big). Staying forever is worth 1/(1−γ)1/(1 - \gamma). For γ=0.9\gamma = 0.9: stay gives 1010, go gives 99, so stay, V∗(A)=10V^*(A) = 10 (check: 1+0.9⋅10=10≥91 + 0.9\cdot10 = 10 \ge 9). For γ=0.5\gamma = 0.5: stay gives 22, go gives 55, so go, V∗(A)=5V^*(A) = 5 (check: 1+0.5⋅5=3.5<51 + 0.5\cdot5 = 3.5 < 5). A patient agent collects small rewards; an impatient one grabs the big one soon.

Needs a step first: 24

Learn it with an AI

Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.

Be my maths tutor. I'm learning "Reinforcement Learning" (Frontier tier): Learning what to do from rewards alone: an agent acts, sees rewards, and improves its policy to maximise discounted future reward.
I already know: Markov Chains, Gradient Descent.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: From state A an agent can "stay" (reward 1, remain in A) or "go" (reward 0, move to B). From B the only action gives reward 10 and ends the episode. Find the optimal value $V^*(A)$ and the best action in A when $\gamma = 0.9$, and again when $\gamma = 0.5$.
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.

On the way to

Recommended