The Essence of Context Bandits
At each step the agent observes a context, picks an action, receives a reward, and updates its belief about which actions pay off in which contexts. The whole game is balancing exploration (trying actions whose payoff is still uncertain) against exploitation (choosing the action that looks best right now).
The decision rule
LinUCB picks the action whose upper-confidence-bound estimate is highest. For each action with feature vector and ridge estimate , the score is:
The first term is exploitation — the predicted reward. The second term is exploration — a bonus that grows with the uncertainty (variance) of the estimate for that action. controls the trade-off.
The update
When reward arrives for action , ridge regression gives a closed-form update — no gradient descent:
So accumulates the outer products of feature vectors (a precision matrix), and accumulates reward-weighted features. The invertibility comes from the ridge regularisation: .
Regret
The quantity a bandit actually minimises is cumulative regret — the gap between what it collected and what the best-fixed action in hindsight would have collected:
A good linear bandit achieves regret — sublinear, meaning the average per-step regret as . That is what “the agent learned” means, formally.
Why it runs on a toaster
The whole algorithm is two matrix multiplies and one solve per step. For the Bandit Fisher demo, is (the RBF feature dimension) — solving it is microseconds. No GPU, no training run, no backprop. The same family of algorithms decides what you see on TikTok.