In tabular Q-learning, when would you prefer a constant learning rate over a decaying one?
answer
- how far one sample moves the estimate
- noise never averages out at fixed steps
- recency weighting versus a settled answer
- sum diverges, sum of squares finite
- count visits per state-action pair
basics
~20 sPrefer a constant learning rate when the environment drifts, because it keeps weighting recent experience and lets the agent track change. Prefer a decaying one when the problem is stationary and you want the convergence guarantee, which a constant rate forfeits.
solid answer
~50 sThe learning rate `alpha` decides how far each sample moves a stored value: `Q <- (1 - alpha) * Q + alpha * target`. Convergence of tabular Q-learning to the optimal action values needs the Robbins-Monro step-size conditions — the step sizes sum to infinity, so any initialisation can be overcome, and their squares sum to a finite value, so sampling noise is damped — plus every state-action pair visited infinitely often. A schedule like `1/n(s,a)`, or `n^-p` with `0.5 < p <= 1`, satisfies both; a constant does not, so values oscillate in a band whose width grows with `alpha`. I still take a small constant rate when the environment drifts — a home battery whose tariffs and household usage shift over months — because a decayed rate eventually freezes the agent and it can no longer track the change. Stationary problem plus a convergence claim to make: decay, counted per state-action pair.
go deeper
Know that the learning rate controls how far each update moves a stored value, and that setting it too large makes the estimates jump around instead of settling.
State the two step-size conditions and give a schedule that satisfies them. Explain why a fixed step size leaves permanent variance when the same action can produce different outcomes.
Diagnose a step-size problem from symptoms — swinging values, a greedy policy that flips between evaluations, noisy plateaued returns — and justify the schedule you switch to.
Own the tradeoff between a convergence guarantee and the ability to track a drifting environment, decide which the system should be optimised for over its lifetime, and name the metrics that will tell you when the choice was wrong.
## What the learning rate actually does Every update in tabular Q-learning has the form ``` Q(s,a) <- Q(s,a) + alpha * ( target - Q(s,a) ) ``` which rearranges to `Q <- (1 - alpha) * Q + alpha * target`. So `alpha` in `(0,1]` is a blend weight: at `alpha = 1` the stored value is thrown away and replaced by a single noisy sample; at very small `alpha` the table barely moves and learning crawls. Unroll the recursion and a constant `alpha` gives an **exponentially recency-weighted average** of all the targets ever seen for that entry, with older ones decaying by `(1 - alpha)` per visit. A decaying `alpha_n = 1/n` gives instead the plain running average of every target seen. That is the whole tradeoff in one line: exponential recency weighting **tracks**, a running average **converges**. ## The convergence conditions Tabular Q-learning converges with probability one to the optimal action values `Q*` under a small set of assumptions: 1. **Coverage** — every state-action pair is visited infinitely often. This is what the behaviour policy must supply; it need not be a good policy, only a sufficiently curious one. 2. **Robbins-Monro step sizes** — for each state-action pair, `sum of alpha_n = infinity` and `sum of alpha_n^2 < infinity`. 3. Bounded rewards and a discount factor `gamma < 1` (or a properly terminating episodic task). The two step-size conditions have plain meanings. The first says the steps must remain large enough, in total, to move the estimate arbitrarily far — otherwise a bad initialisation is never escaped. The second says they must shrink fast enough that the accumulated sampling noise is finite — otherwise the estimate keeps being knocked around forever. A schedule `alpha_n = n^-p` satisfies both exactly when `0.5 < p <= 1`; `1/n` is the boundary case, and anything decaying faster than `n^-1` fails the first condition. Crucially, `n` here should be the **visit count for that state-action pair**, not the global step counter. Decaying on wall-clock steps starves rarely visited pairs: by the time they are first sampled, their step size is already tiny and they never learn anything. ## What a constant rate costs you A constant `alpha` fails the second condition, and the failure is visible rather than theoretical. On a stochastic environment — say a windy grid where the same action from the same cell sometimes lands somewhere else — the target is a random variable, and with a fixed step size the estimate never stops chasing the newest draw. The values settle into a band around the truth rather than onto it, and the width of that band grows roughly with `alpha`. Set `alpha` high enough and the symptoms are unmistakable: values for frequently visited pairs swing between evaluations, the greedy policy read off the table flips back and forth, and the average return plateaus at a noisy level well below what the problem allows. The fix is boring — halve the rate and see whether the band narrows and the policy stops churning. Note what does *not* happen: tabular Q-learning with a too-large `alpha` thrashes, it does not blow up the way an over-large step can in a parametric model, because each table entry is bounded by the returns it is averaging. "It diverged" is usually the wrong diagnosis here. ## When you deliberately give up the guarantee The convergence proof assumes a **stationary** MDP: fixed transition probabilities, fixed rewards. Plenty of real problems are not. Consider a tabular agent over discretised battery charge levels deciding each hour whether to charge, hold or sell. Tariff structures change, the household's consumption pattern changes with the season, the battery itself ages. The optimal action values genuinely move. A decayed step size in that setting is actively harmful: after a few months the effective learning rate is near zero, the agent is frozen onto a world that no longer exists, and no amount of new evidence can shift it. A small constant rate keeps a rolling window of relevance and lets the table follow the drift, at the price of permanent jitter. So the decision is not "which is correct" but **what the system is being optimised for over its lifetime**: - One-off training against a simulator, a fixed problem, a result you want to claim is optimal → decay per state-action visit count, with the exponent in the valid range. - A long-lived agent in a moving world → small constant rate, accept the noise, and blunt it downstream by acting on smoothed values or by requiring a margin before the greedy action is allowed to switch. - A middle path that is often the pragmatic answer: decay to a floor rather than to zero, which keeps a residual ability to adapt while spending most of the run in the low-noise regime. Whichever you pick, make the choice explicit and monitored. Track policy churn (how often the greedy action changes for high-traffic states) and the spread of a few representative values; those two series tell you within an evaluation cycle whether your step size is too hot or already frozen.
- State the step-size conditions that a convergence proof for tabular Q-learning requires.For each state-action pair, the step sizes must sum to infinity and their squares must sum to a finite value — large enough in total to escape any initialisation, small enough eventually to damp sampling noise. `alpha_n = 1/n(s,a)`, or `n^-p` with `p` strictly above 0.5 and at most 1, qualifies. They are paired with the requirement that every state-action pair is visited infinitely often.
- How would you tell from monitoring that the learning rate is set too high?Values for frequently visited state-action pairs swing between evaluation points instead of narrowing, the greedy action for high-traffic states flips back and forth, and average return plateaus noisily below what the problem should allow. Halve the rate: if the spread narrows and the policy stops churning while returns hold, the step size was the cause.
- Why should the decay be indexed by visit count rather than by total training steps?Because the schedule is meant to average out noise in one table entry. Indexing on global steps means a state-action pair first reached late in training already has a near-zero step size and can never learn its value, while high-traffic pairs decay at the right pace. Count visits per entry and every pair gets its own full learning curve.
A constant step size is a thermostat that reacts to every draft: quick to follow a real change in the room, never perfectly steady.
saying these in an interview costs you the question
- Says a constant learning rate still guarantees convergence
- Claims a decaying rate is always the right choice
- Confuses the learning rate with the discount factor
- Decays the step size on total steps rather than per state-action visits
- Calls a thrashing tabular agent divergence rather than step-size noise