Reinforcement Learning

Exploration and Exploitation

Exploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

status: reviewimportance: importantdifficulty 3/5math: graduateread: 24mlive demo

Concept Structure

Exploration and Exploitation

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

1prerequisites
2next concepts
3related links

Learner Contract

What this page should let you do.

You are here becauseExploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

This Reinforcement Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.

Before thisBandits (review)

1 prerequisite listed; refresh them before leaning on the math or code.

By the end4/4 sections ready | runnable code expected | live demo

Explain the mechanism, trace the main notation, and test one prediction in the live demo.

Do this firstIntuition

Read the intuition before the notation; the math should name a mechanism you already felt.

Then go nextQ-Learning and SARSA (review)

Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.

Test the linkManipulate one control and predict the visible change.Then continue to Q-Learning and SARSA (review)

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.
Claims1/1 reviewed
Sources3 cited
Codeattached
Demolive
Reviewed2026-07-03
Updatedpage 2026-07-03

Learning item flow

4/4 sections readyAsk about thisResearch room
ConceptExploration and ExploitationReinforcement Learning
3 sources attachedLocal snapshot ready
concept:reinforcement-learning/exploration-exploitation
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

Exploration and exploitation is not "curiosity versus greed" as a personality trait. It is a horizon problem.

At a single decision, exploitation is usually right: choose the arm with the largest current estimate and collect the reward that looks best. Across many decisions, that can fail. If the estimate is wrong because early samples were lucky or unlucky, the learner keeps training on data produced by its own mistake.

Exploration deliberately spends some reward opportunity to learn. That cost is real: trying a worse-looking arm can create immediate regret. The reason it can still be rational is that the information affects future choices. One exploratory pull may prevent many later exploitative pulls from going to the wrong action.

The key phrase is selected feedback. The learner only sees the reward for the action it took. Pulling Arm A does not reveal what Arm C would have paid. So every policy is also a data-collection policy.

Three behaviors are worth separating:

  • Greedy exploitation follows the largest current estimate and can lock in when early evidence is misleading.
  • Epsilon-greedy keeps a small random exploration budget, so every action can still receive samples.
  • UCB explores more deliberately by adding an uncertainty bonus to under-sampled actions.

Regret is the accounting system that makes the tradeoff visible. Exploration may increase regret today, but if it identifies the better action, it can lower cumulative regret over the horizon.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Start with a stationary finite bandit. Each arm aa has an unknown mean reward

μa=E[RtAt=a],\mu_a = \mathbb E[R_t \mid A_t = a],

and the best mean is

μ=maxaμa.\mu_\star = \max_a \mu_a.

The learner maintains an estimate Qt(a)Q_t(a) from the rewards it actually observed after choosing arm aa. If Nt(a)N_t(a) is the number of observed pulls of arm aa before round tt, then a sample-average estimate is

Qt(a)=1Nt(a)i<t:Ai=aRi.Q_t(a) = \frac{1}{N_t(a)} \sum_{i < t: A_i = a} R_i.

Greedy exploitation chooses

At=argmaxaQt(a).A_t = \arg\max_a Q_t(a).

This maximizes the current estimate, not necessarily the true mean. If an early lucky arm has a high Qt(a)Q_t(a) and an early unlucky arm has a low Qt(a)Q_t(a), greedy selection can stop gathering the data that would correct the mistake.

Epsilon-greedy forces continued sampling:

At={argmaxaQt(a),with probability 1ϵ,a random arm,with probability ϵ.A_t = \begin{cases} \arg\max_a Q_t(a), & \text{with probability } 1-\epsilon, \\ \text{a random arm}, & \text{with probability } \epsilon. \end{cases}

UCB turns uncertainty into an action score:

At=argmaxa[Qt(a)+clntNt(a)].A_t = \arg\max_a \left[ Q_t(a) + c\sqrt{\frac{\ln t}{N_t(a)}} \right].

The first term exploits the estimate. The second term explores arms with small Nt(a)N_t(a). After an arm is sampled, its count grows and the bonus shrinks.

The expected regret of one action is

μμAt.\mu_\star - \mu_{A_t}.

The cumulative pseudo-regret over a horizon TT is

RˉT=t=1T(μμAt).\bar R_T = \sum_{t=1}^{T} \left(\mu_\star - \mu_{A_t}\right).

This is why exploration cannot be judged from one reward. A low reward on a useful probe can still improve the future action sequence.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import math

true_mean = {"A": 0.55, "B": 0.45, "C": 0.72}
pulls = {"A": 3, "B": 2, "C": 1}
successes = {"A": 3, "B": 1, "C": 0}

plans = {
    "greedy": ["A", "A", "A", "A", "A", "A", "A", "A"],
    "epsilon": ["A", "C", "A", "B", "C", "A", "C", "C"],
    "ucb": ["C", "A", "C", "C", "A", "C", "C", "C"],
}

def estimate(arm):
    return successes[arm] / pulls[arm]

best = max(true_mean.values())

for name, actions in plans.items():
    regret = 0.0
    local_pulls = pulls.copy()
    local_successes = successes.copy()
    for arm in actions:
        regret += best - true_mean[arm]
        local_pulls[arm] += 1
        local_successes[arm] += int(true_mean[arm] > 0.5)
    final_q = {a: local_successes[a] / local_pulls[a] for a in true_mean}
    print(name, "regret", round(regret, 3), "final estimates", final_q)

q = {a: estimate(a) for a in true_mean}
ucb = {a: q[a] + 0.8 * math.sqrt(math.log(7) / pulls[a]) for a in true_mean}
print("current estimates", q)
print("ucb scores", ucb)

The starting estimates make Arm A look safest, even though Arm C has the largest true mean. The difference between policies is not their first reward. It is the future data they cause themselves to collect.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

Use the Regret Horizon Lab to predict which exploration behavior explains an eight-pull plan.

Inspect the starting estimates and counts, choose the behavior that best explains the hidden pull tape, and reveal only after committing. The lab then shows true means, policy regret, reward tape, and why an information cost can be better than greedy lock-in.

Live Concept Demo

Explore Exploration and Exploitation

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5graduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what Exploration and Exploitation 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

Exploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

Prediction open01 / Intuition
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Exploration and Exploitation should make visible.

Visual Inquiry

Make the image answer a mathematical question

Exploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Exploration and Exploitation easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

book · 2018Reinforcement Learning: An Introduction, Second EditionRichard S. Sutton and Andrew G. Barto

Canonical source for the exploration/exploitation dilemma, selected evaluative feedback, epsilon-greedy action selection, UCB action selection, and greedy long-run failure on bandit testbeds.

Open source
course-notes · 2026Stanford CS234: Lecture 1, Introduction to Reinforcement LearningStanford CS234

Graduate RL source for exploration as decision-dependent information: decisions affect what the learner observes, and rewards are only observed for decisions actually made.

Open source
book · 2020Bandit AlgorithmsTor Lattimore and Csaba Szepesvari

Graduate source for finite-armed regret, pseudo-regret, explore-then-commit tradeoffs, epsilon-greedy context, and optimism via upper confidence bounds.

Open source

Claim Review

Exploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources3 references

sutton-barto-2018-rl, stanford-cs234-intro-rl-2026, lattimore-szepesvari-2020-bandit-algorithms

Local checks4 local checks

Use equations, runnable code, and demos to check whether the source support is operational.

Substantively reviewedExploration pays information cost now to reduce future regret; greedy exploitation can lock onto early noise, while epsilon-greedy and UCB keep sampling uncertain actions in different ways.Claim metadata: source checked

The sources support the selected-feedback setting, the one-step versus long-run reward tradeoff, greedy lock-in under early noise, random exploration in epsilon-greedy, directed exploration through UCB optimism, and regret as the expected cost of action choices against the best arm.

Sources: Reinforcement Learning: An Introduction, Second Edition, Stanford CS234: Lecture 1, Introduction to Reinforcement Learning, Bandit AlgorithmsStationary finite Bernoulli bandit horizon lab only; excludes contextual/adversarial/nonstationary bandits, Thompson sampling, MDP exploration bonuses, proofs, and offline RL.A bounded review summary is present; still check caveats and exact reference scope.

Checked Sutton/Barto Chapter 2, Stanford CS234 Lecture 1, and Lattimore/Szepesvari Chapters 6-7 for selected feedback, greedy lock-in, epsilon-greedy, UCB optimism, explore-then-commit tradeoff, and regret framing. GPT Pro critique remains pending because 127.0.0.1:51672 is unavailable.

Reviewer: codex-local-source-review; reviewed 2026-07-03

Practice Loop

Try the idea before it explains itself

Exploration and exploitation is the horizon tradeoff: take known reward now, or spend pulls reducing uncertainty so future actions regret less.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Exploration and Exploitation.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded research drawerClose
ConceptExploration and ExploitationReinforcement Learning

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.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptReinforcement Learning

Exploration and Exploitation

Attached question

What is the smallest example that makes Exploration and Exploitation click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays in this browser, attached to the selected learning item.

No local draft saved.
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
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Exploration and Exploitation Selected item key: recorded for copy. Context: Reinforcement Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes Exploration and Exploitation 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.

View it in context
concept/concept-notebook/reinforcement-learning/exploration-exploitation concept:reinforcement-learning/exploration-exploitation