Worked examples — Epsilon-greedy strategy
This is a deep-dive companion to Epsilon-greedy strategy. The parent note built the idea: flip a biased coin, exploit most of the time, explore sometimes. Here we grind through every kind of situation that idea can produce — every value of , every degenerate input, the limits, and the traps an exam loves.
Before a single number: let us re-anchor every symbol we will use over and over, so no symbol appears un-earned.
The single formula that generates every answer on this page:
The scenario matrix
Every situation epsilon-greedy can throw at you falls into one of these cells. The examples below are labelled with the cell they cover, and together they fill the whole grid.
| Cell | Case class | What is special | Example |
|---|---|---|---|
| A | Ordinary fixed | , estimates converged | Ex 1 |
| B | Degenerate | Pure greedy, no exploration | Ex 2 |
| C | Degenerate | Pure random, no exploitation | Ex 3 |
| D | Single action | Nothing to explore | Ex 4 |
| E | Tie in -values | ambiguous | Ex 5 |
| F | Running-average update | Incremental formula, step by step | Ex 6 |
| G | Limiting behaviour | , cumulative regret grows without bound | Ex 7 |
| H | Decaying schedule | , policy becomes greedy | Ex 8 |
| I | Real-world word problem | Translate a story into | Ex 9 |
| J | Exam twist | "Solve for given a target regret" | Ex 10 |
The figure below turns the "two doors" idea into a picture — study it before Example 1, because every example that follows is just re-counting these two coloured stacks.

Look at the chart: the blue block is the exploit door and sits only on the best arm ; the thin orange slivers are the explore door and appear on every arm equally. The best arm's total bar (blue + orange) rises above the dashed line — that little orange cap is exactly the bonus explored in Example 1.
Worked examples
- Explore door for the best arm. Explore happens with ; a uniform pick among hits with . So this door contributes . This is the orange cap on the bar in the figure above. Why this step? We must count the explore path separately because even the best arm can be chosen by luck during exploration.
- Exploit door for the best arm. Exploit happens with , and since is estimated-best, this whole flows to it — the blue block in the figure. Why this step? The exploit door opens only for the current ; here that is .
- Add the doors. .
- Each other arm. No exploit door (they are not the max), only explore: each — the lone orange slivers.
Verify: total probability must be . . ✓ Also — the best arm beats because exploration occasionally helps it too.
- Find the estimated-best. (value , others ). Why this step? Pure greedy always picks the current , nothing else.
- Check the explore door. With , . That door is nailed shut. Why this step? Every alternative arm can only be reached by exploration; with none, they are unreachable.
- Consequence. and stay stuck at forever; the agent replays every step.
Verify: . The truly-best arm has probability exactly . This is the failure the whole strategy exists to prevent.
- Kill the exploit door. , so exploitation never happens. Every arm is chosen purely by the uniform explore pick . Why this step? With the is irrelevant; -values do not influence the choice.
- Best-arm probability. , same as everyone. Why this step? Since the choice is now purely uniform, the best arm is just one of the equally-likely options — no exploit bonus can lift it.
- Expected regret per step. . Why this step? Regret is the average lost reward, so weight each gap by its pick probability .
Verify: all probabilities sum to ✓. Regret is the largest this bandit can produce — pure random is the worst exploiter, confirming exploration alone is not the goal.
- Exploit door. With we exploit; the only arm is the , so it gets . Why this step? The exploit door always flows to the ; with a single arm, that arm is trivially the maximum, so it collects the entire .
- Explore door. With we explore, then uniform over arms gives . So this door contributes . Why this step? "Uniform random over one option" always returns that option — explore is not wasted, it just re-selects the same arm.
- Add. .
Verify: , and . With one arm the strategy is a no-op — a good sanity boundary.
- Split the exploit door across the tie. Exploit probability is shared equally by the two tied arms: each gets . Why this step? returns a set here; a uniform tie-break shares the exploit mass.
- Add 's explore door. . Why this step? Exploration still visits every arm uniformly regardless of the tie, so collects its usual on top of its half-share of the exploit door.
- Total for . .
Verify: by symmetry , and . Sum ✓.
The incremental update (why it exists: it avoids storing every past reward): Here is the step size, and is the prediction error (how surprised we were).
- Pull 1. . Why this step? First reward becomes the estimate outright.
- Pull 2. . Why? Reward was below our guess, so the error is negative and drops.
- Pull 3. .
- Pull 4. .
Verify: plain average . ✓ The incremental rule reproduces the batch mean exactly — the same idea that powers 3.4.07-Stochastic-Gradient-Descent and value updates in 6.3.02-Q-Learning.
- Suboptimal pick probabilities. Each non-best arm has . Why this step? Once estimates converge, the exploit door flows entirely to , so every other arm is reachable only through the explore door's uniform — that is exactly the probability that costs us regret.
- Per-step regret. . Why this step? Only suboptimal arms cost regret; weight each gap by its pick probability.
- Cumulative over . Because is fixed, is constant, so total regret . Why this step? A constant per-step loss added times grows linearly and never flattens.
Verify: per step, cumulative at . Linear (not bounded) regret is the signature weakness of fixed- — the motivation for 5.1.09-Upper-Confidence-Bound and 5.1.10-Thompson-Sampling, which achieve sublinear regret.
- Raw decay at . . Since , . Why this step? Repeated multiplication by is exponential decay; logs turn the power into a product we can estimate.
- Compare to floor. , so the returns the raw decay: — floor not yet active. Why this step? The schedule takes whichever is larger, the decaying value or the floor ; here the decay still dominates, so the floor has no effect yet.
- When does the floor bite? Solve : . Why this step? Set raw decay equal to the floor; beyond this the picks .
Verify: ✓; floor engages at . After that the policy explores only , nearly greedy — and if were the policy would converge to pure greedy, the only regime with vanishing regret. Trace this on the figure below.

In the figure the grey dashed curve is the raw exponential decay ; the solid blue line is the actual the agent uses, which hugs the decay until it flattens onto the red dotted floor. The orange dot marks (still high, ); the green dot marks where decay meets the floor at — exactly the value we solved for in step 3.
- Explore visitors. A fraction of visitors are in explore mode. Why this step? Since estimates have converged, exploitation always shows C; exploration is the only channel that shows any non-C banner.
- Split explore uniformly. Each arm gets explore visitors, including C itself. Why this step? The explore door picks uniformly over all arms, so the 800 explore visitors divide equally — no arm is favoured during exploration, not even the best one.
- Non-C total. The three non-C arms get explore visitors. (C also gets explore + all exploit visitors.) Why this step? "Non-best shown" = explore visitors that landed on the other three arms.
- Banner A specifically. . Why this step? Banner A is never the estimated-best, so it is reached only through the explore door with probability ; multiply by the visitors to get a count.
Verify: non-C , banner A . Check totals: C exploit + C explore shown C; ✓. Under visitors touched non-best banners — the unavoidable cost of learning, echoing 5.2.04-Exploration-vs-Exploitation.
- Write per-step regret. Only the suboptimal arm costs regret, with pick probability . So . Why this step? With there is exactly one bad arm, reached only by exploration at rate ; its gap turns that probability into regret.
- Set the budget. Require . Why this step? The boss's cap is a ceiling on ; we translate the requirement directly into an inequality on .
- Solve. . Why this step? Divide both sides by the coefficient to isolate ; the largest allowed value is the equality case .
Verify: plug back: exactly ✓. So — matching the boss's ceiling on the nose.
Recall
Recall Every cell in one line
Fixed , arms — best-arm pick probability? ::: and first sample was unlucky — does it recover? ::: No; the truly-best arm has probability forever (Cell B). on arms — probability of any specific arm? ::: (pure random, Cell C). Single arm — effect of ? ::: None; probability is regardless (Cell D). Two-way tie in , uniform break, -greedy — exploit mass per tied arm? ::: (Cell E). Why does cumulative regret grow linearly for fixed ? ::: Per-step regret is a positive constant; adding it times gives (Cell G). To make the policy converge to pure greedy, what must do? ::: Decay to over time (Cell H).