Multi-armed bandits
A one-armed bandit is a slot machine. A multi-armed bandit is a row of them, each paying out at its own unknown rate, and you only get so many pulls. Every pull spends one of two things: reward, or information about which machine to pull next. You cannot buy both with the same coin.
That trade is the whole subject of this chapter. It is reinforcement learning with state and delayed consequences deleted, leaving the one difficulty that neither supervised learning nor planning has to face — the learner has to act in order to find out what acting is worth.
Learning objective
Section titled “Learning objective”Understand why exploration is necessary at all, and be able to state the exploration–exploitation trade-off precisely enough to measure it.
The setup
Section titled “The setup”You face slot machines. Each machine pays out according to a fixed but unknown distribution with mean :
At each step you pick one machine and receive one reward. The distributions never change. You get 1000 pulls. Maximise the total.
That is the whole problem. There is no state — the situation after 500 pulls is identical to the situation at the start, apart from what you have learned. There is no delayed consequence — the reward arrives immediately and affects nothing else.
Why strip it down this far
Section titled “Why strip it down this far”Removing state and delay leaves exactly one difficulty behind: you cannot learn about an action without giving up reward.
If you knew every , the problem would be trivial — always pull the best machine. You do not, so you hold estimates . At any moment:
- Exploiting means picking : the best return given what you currently believe.
- Exploring means picking something else: worse in expectation right now, but it improves the estimate that all your future decisions depend on.
You cannot do both on the same pull. Every algorithm in this chapter is a different answer to when is a worse action worth taking?
A simple bandit algorithm
Section titled “A simple bandit algorithm”Here is a complete agent for the problem, in eight lines. Everything else in the chapter is an explanation of one of them.
A simple bandit algorithm
Initialise, for to :
Loop forever:
Three pieces are doing the work, and each gets a page of its own:
- and — the estimate of and the count it averages over. Why the running average is written incrementally rather than recomputed is action-value methods.
- The choice of — the coin flip that decides exploit or explore on this step, and how much that choice costs, is epsilon-greedy.
- — the environment. It draws a reward from the unknown distribution behind arm and tells you nothing else. No transition, no next state; the loop returns to exactly where it started.
Two details in that box are easy to skim past and expensive to get wrong.
Ties must be broken randomly — with every starting at 0, the first
step is a -way tie, and an argmax that returns the lowest index turns the
agent into one that only explores by accident. And the step size is
, the count for the arm actually taken, not the global step number.
Measuring how well you did
Section titled “Measuring how well you did”Total reward alone is a poor yardstick, because a lucky run on an easy set of arms beats a smart run on a hard one. Two better measures:
Percent optimal action — the share of pulls that hit the truly best arm. It goes to 100% for a method that eventually finds and keeps the best arm.
Regret — the reward you gave up by not always playing the best arm:
Regret only ever increases. What matters is how fast. A method that keeps exploring at a fixed rate accrues regret linearly forever; a method that anneals its exploration can get sublinear regret.
Contents
Section titled “Contents”- Action-value methods — how to estimate from experience.
- Epsilon-greedy — the simplest exploration rule that works, with an interactive simulator.
- Tracking a nonstationary problem — what changes when drifts, and why the step size is really a memory length.
- Optimistic initial values — how a starting value alone can make a greedy agent explore, and why only once.
- Upper-confidence-bound action selection — explore the arm you are least sure about, and why the learning curve spikes at step 11.
- Gradient bandit algorithms — learn preferences rather than values, derived as stochastic gradient ascent, and what the baseline is really for.
Personal takeaways
Section titled “Personal takeaways”The bandit problem is worth taking seriously rather than treating as a warm-up. Nearly every exploration idea in deep RL — optimistic initialisation, upper confidence bounds, decaying — is a bandit idea that got carried into a larger setting mostly unchanged.
References
Section titled “References”- Sutton, R. S. & Barto, A. G. Reinforcement Learning: An Introduction, 2nd ed., ch. 2.