Learn

Learning preferences

Make learning more comfortable. Changes apply immediately.

Enlarges page content, including diagrams and their labels. You can also use your browser’s zoom.

Choose the colours that are easiest for you to distinguish. Applies to lesson diagrams and lab plots. Labels, shapes, hatching and line patterns also distinguish meanings. Source photographs and raw image brightness stay unchanged; mask-only views are available for image overlays.

ExampleComparisonSample link

Saved in this browser on this device. Preferences are separate from progress backups.

Lesson 1 of 14 in this unit

Build AI Systems · SOURCE LESSON 10

Explore before you decide.

Choose between uncertain rewards and discover why trying a new option can improve later decisions.

By the end: Explain exploration and exploitation, read an action-value estimate, and calculate a policy’s expected reward.

Start with the exampleJump to the experimentRead the explanation
Prerequisites and path options

Why learn this? Understand why trying an uncertain option can improve later decisions, even when it costs something now.

01 · TRY

Start with something concrete.

Three unfamiliar snack machines sometimes give you a free snack. Each has a different chance of success, but you do not know those chances. Should you keep using the first machine that worked, or spend some turns investigating the others?

Try the interactive model
02 · PREDICT
Before you experiment

An arm gave reward 1 on its first pull. What can you conclude?

An arm gave reward 1 on its first pull. What can you conclude?
03 · EXPERIMENT

Change one thing. Watch what follows.

Loading this browser experiment…

04 · UNDERSTAND
READ & CONNECT

Understand what changed.

Back to the experiment

A shorter explanation, with the original worked examples available below. Both explain the same experiment and its limits.

Same learning goal in both modes: Explain exploration and exploitation, read an action-value estimate, and calculate a policy’s expected reward.

The idea in everyday terms

An agent chooses an option and receives a reward. Trying only the option that currently looks best can hide a better alternative. Exploration means sometimes trying something else to improve the evidence for future choices.

What to watch in the experiment

The bandit records rewards for each option and updates its average estimate. The epsilon setting controls how often it explores rather than taking the current favorite. Compare the reward earned now with what the agent learns about less-tested options.

What this does not establish

The lab uses a small table and a programmed choice rule. It is not a neural actor–critic system, and success on these fixed options does not establish good decisions in changing environments.

Open the full worked examples, calculations and limitations

This is the same reference used in Technical mode. Expand it whenever you need the exact numbers, assumptions or further explanation.

Learn from consequences

In supervised learning, we supplied a desired answer for each input. In reinforcement learning, an agent chooses an action, receives a reward, and may enter a new state. Its choices affect what experience it collects. The objective is usually to increase expected accumulated reward, not to copy a labeled action on every turn.

The three-arm experiment is a bandit: each choice gives an immediate reward without changing a useful future state. Its hidden reward probabilities are 0.2, 0.5, and 0.8, matching the source example. Each outcome is either 0 or 1. A probability of 0.8 means an average of about eight successes per ten pulls over many repetitions, not a guarantee about the next ten.

Explore or exploit?

Exploitation chooses the action with the largest current estimate. Exploration tries alternatives to collect evidence. Our ε-greedy policy explores with probability ε and otherwise exploits. Exploration chooses uniformly among all three arms, including the current favorite.

With ε = 0.3, each arm receives 0.3 / 3 = 0.1 probability from exploration. The current favorite also receives the remaining 0.7, for a total probability of 0.8. ε is a design choice: too little exploration can miss a better option; continued random choices can reduce reward once good estimates are available. This lab keeps ε fixed until you change it.

At the start all estimates are zero. The tie rule chooses A. With ε = 0, the learner never discovers B or C: A’s estimate cannot fall below their initial zero. That is a property of this initialization and tie rule, not a theorem that every greedy learner always fails.

Three different value questions

An action value Q asks: “How much return do I expect if I take this action?” For this one-step bandit, we estimate it using the observed average reward for that arm. An untried arm is initialized to zero, which is a starting guess rather than an observation.

Qnew=Qold+r−QoldnQ_{\mathrm{new}}=Q_{\mathrm{old}}+\frac{r-Q_{\mathrm{old}}}{n}

Here n counts this arm’s pulls, including the latest. If an arm has produced rewards 1, 0, 1, its estimate is 2/3. A fourth reward of 0 changes it to 2/3 + (0 − 2/3)/4 = 1/2.

A state value V asks: “How good is this situation under my policy?” In this bandit, the situation is always the same. Multiply each action estimate by the probability of choosing that action, then add.

V=∑aπ(a)Q(a),A(a)=Q(a)−VV=\sum_a\pi(a)Q(a),\qquad A(a)=Q(a)-V

The advantage A compares an action with the policy’s baseline. A positive advantage means better than that estimated baseline, not certain success. In a multi-step task, Q and V refer to future accumulated rewards under specified behavior, not merely the next reward.

From a table to actor–critic learning

An actor selects actions using a policy. A critic estimates value and supplies feedback that can help improve the policy. Advantage estimates can guide the actor toward actions that did better than expected. Larger systems can represent the policy and critic with neural networks and update their weights using gradients.

Our bandit instead uses a small table and a programmed ε-greedy policy. Its Q, V, and A values make those ideas visible, but it does not implement a neural actor–critic optimizer. The next lesson introduces changing states and delayed consequences.

05 · APPLY
Check your understanding

After many pulls, Q estimates are 0.2, 0.5, and 0.8. With ε = 0.3, random exploration chooses each arm equally. What is the next policy’s estimated reward?

After many pulls, Q estimates are 0.2, 0.5, and 0.8. With ε = 0.3, random exploration chooses each arm equally. What is the next policy’s estimated reward?
06 · CONTINUE

Take this idea with you.

A learner needs evidence about alternatives. Exploration trades some immediate reward for information; value estimates and observed success rates remain uncertain.

My Learning
Explore related topics and the topic map

How this topic connects

Explore this topic on the interactive map

Use these connections to review a foundation or choose where to go next. You can open any topic without completing the others.

What it builds on

  • Averages and probability

    Combine outcomes with their frequencies or probabilities, keeping the denominator explicit when interpreting this lesson’s evidence.

  • Training and testing

    Avoid choosing a model that memorizes examples but fails on new ones.

You are hereExplore before you decide

Choose between uncertain rewards and discover why trying a new option can improve later decisions.

What it enables

Show 3 more connections