This Reinforcement Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Reinforcement Learning
Temporal-Difference Learning
Temporal-difference learning updates a state value after one sampled transition by comparing the old value with a reward-plus-next-value target.
Concept Structure
Temporal-Difference Learning
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
2 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Monte Carlo RL waits for the episode to end. Bellman backups use a known model to average over possible next states.
Temporal-difference learning sits between those two ideas. It looks at one real transition,
then asks:
If the next state's current value estimate is my best guess of what happens from there, how wrong was my current value estimate?
That question is the learning move. TD does not wait for the complete return . It also does not need the transition probabilities that a Bellman expectation backup needs. It uses the sampled reward plus the current value estimate of the sampled next state.
The price is that the target is partly made from an estimate. That is bootstrapping. The benefit is that the learner can update online, one transition at a time.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Assume a fixed policy in a finite discounted MDP. At time , the agent is in state , takes the action prescribed or sampled under , receives reward , and lands in .
TD(0) builds the one-step target
where is the current value estimate of the sampled next state. If is terminal, use .
The TD error is the gap between that one-step target and the current estimate:
Then TD(0) moves the current state's value estimate by a learning-rate-scaled error:
Equivalently,
That last form shows the exponential-moving-average view: keep part of the old estimate and mix in the new sampled target.
The comparison is the core idea:
- Monte Carlo target: , a complete sampled return.
- Bellman expectation target: , a model average.
- TD(0) target: , one sampled step plus a bootstrapped next value.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
gamma = 0.90
alpha = 0.40
values = {"Start": 1.20, "Practice": 1.80, "Confused": 0.80, "Mastered": 0.0}
stream = [
("Start", "drill", 1.0, "Practice"),
("Practice", "repeat", -0.6, "Confused"),
("Confused", "ask", 0.7, "Practice"),
]
for state, action, reward, next_state in stream:
bootstrap = 0.0 if next_state == "Mastered" else values[next_state]
target = reward + gamma * bootstrap
td_error = target - values[state]
update = alpha * td_error
values[state] += update
print(
state,
action,
"target", round(target, 3),
"error", round(td_error, 3),
"new", round(values[state], 3),
)
Notice the online dependence: the third line uses the already-updated Practice value. TD learning is not just a formula applied to a frozen table; it is a stream of value repairs.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Use the Temporal-Difference Update Lab to predict which state value changes most after a short sampled transition stream.
Choose a stream, inspect the current values and the sampled transitions, then commit to the state whose estimate should change most. After reveal, the lab shows the TD target, TD error, learning-rate-scaled update, and before/after value table for every transition.
The comparison strip keeps the boundary clear: Monte Carlo waits for a complete return, a Bellman backup needs model probabilities, and TD updates now from one sampled transition plus a bootstrapped next value.
Live Concept Demo
Explore Temporal-Difference Learning
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Temporal-Difference Learning should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Temporal-difference learning updates a state value after one sampled transition by comparing the old value with a reward-plus-next-value target.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Temporal-Difference Learning should make visible.
Visual Inquiry
Make the image answer a mathematical question
Temporal-difference learning updates a state value after one sampled transition by comparing the old value with a reward-plus-next-value target.
Which visible object should carry the first intuition?
Pick the cue that should make Temporal-Difference Learning easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Canonical source for TD learning as a combination of Monte Carlo experience and dynamic-programming bootstrapping, TD(0), one-step TD targets, and TD error.
Open sourceGraduate RL source for TD(0) targets, TD error, immediate update after an observed transition, and MC-vs-TD bias/variance framing.
Open sourceCourse-note source for passive model-free learning, temporal-difference sample values, exponential-moving-average update, and the Q-learning downstream bridge.
Open sourceClaim Review
Temporal-difference learning updates a state value after one sampled transition by comparing the old value with a reward-plus-next-value target.
Claims without a substantive review badge still need exact source-support review.
sutton-barto-2018-rl, stanford-cs234-td-learning, berkeley-cs188-model-free-learning
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support finite tabular TD(0) policy evaluation as a model-free, one-step sample update that bootstraps from the current next-state value estimate instead of waiting for a complete Monte Carlo return or averaging over a known transition model.
Sources: Reinforcement Learning: An Introduction, Second Edition, Stanford CS234: Lecture 3, Model-Free Policy Evaluation, UC Berkeley CS188: Model-Free LearningFinite tabular on-policy teaching MDP only; excludes TD control, SARSA, Q-learning, n-step returns, eligibility traces, off-policy corrections, convergence proofs, stochastic-approximation schedules, continuing-task average reward, and function approximation.A bounded review summary is present; still check caveats and exact reference scope.Checked Sutton/Barto Chapter 6 for TD as the combination of Monte Carlo experience and DP bootstrapping, the TD(0) update, one-step TD target, and TD error; checked Stanford CS234 Lecture 3 for target/error/update framing and immediate update after an observed transition; checked Berkeley CS188 model-free learning notes for passive TD learning as a sample-value exponential update. GPT Pro publication critique remains pending because 127.0.0.1:51672 is unavailable.
Reviewer: codex-local-source-review; reviewed 2026-07-03Source support candidates
book 2018Reinforcement Learning: An Introduction, Second EditionCanonical source for TD learning as a combination of Monte Carlo experience and dynamic-programming bootstrapping, TD(0), one-step TD targets, and TD error.
course-notes 2026Stanford CS234: Lecture 3, Model-Free Policy EvaluationGraduate RL source for TD(0) targets, TD error, immediate update after an observed transition, and MC-vs-TD bias/variance framing.
course-notes 2026UC Berkeley CS188: Model-Free LearningCourse-note source for passive model-free learning, temporal-difference sample values, exponential-moving-average update, and the Q-learning downstream bridge.
Practice Loop
Try the idea before it explains itself
Temporal-difference learning updates a state value after one sampled transition by comparing the old value with a reward-plus-next-value target.
Before touching the demo, predict one visible change that should happen in Temporal-Difference Learning.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Temporal-Difference Learning
What is the smallest example that makes Temporal-Difference Learning click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Temporal-Difference Learning Selected item key: recorded for copy. Context: Reinforcement Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes Temporal-Difference Learning click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/reinforcement-learning/temporal-difference-learning
concept:reinforcement-learning/temporal-difference-learning