A replay buffer holds transitions with absolute TD errors . Prioritised experience replay samples transition with probability with and . Compute the sampling probabilities and the importance-sampling weights (normalised by their maximum) for and . Why are the weights needed?
Reinforcement learning, Deep Q-networks
Level L4 Advanced. Length Medium. Nature Th+Mat Both.
What's being asked
Whether you can compute prioritised sampling probabilities and see that non-uniform sampling biases the gradient unless corrected.
Key idea
Prioritised replay samples transitions with a large TD error more often, which speeds up learning but changes the data distribution, so the gradient is biased. Multiplying each loss term by undoes the bias, fully when .
Steps
- Compute . Their sum is .
- Probabilities: . Check the sum: . With uniform replay each would be .
- Raw weights are for . Normalising by the largest weight (that of the smallest ) gives .
- For , take square roots: . A smaller corrects less.
- Explain why weights are needed. The loss is meant to be an average over the buffer's distribution, . If is drawn with probability , then , so the factor restores the unbiased average.
- Explain the choices. gives uniform sampling, and gives fully proportional sampling. is annealed from a small value to during training, because bias matters most near convergence. Weights are divided by the maximum to keep the update size stable.
- Add implementation facts. Priorities are stored in a sum-tree for sampling, new transitions get the maximum priority so that each is replayed at least once, and a small constant is added to so no priority is zero.
Common mistakes
- Applying the weights to the sampling probabilities rather than to the loss. They multiply the per-sample loss, or its gradient.
- Assuming every stored priority is up to date. Priorities are refreshed only for the transitions just replayed, so the others can be stale.
- Saying is best from the start. It makes the early updates small and slows learning, so it is annealed.
How long your answer should be
Half a page; 5 minutes.
Last checked on 4 December 2026.
Read this
Previous in Reinforcement learning: Sketch why UCB1 has regret growing only like . For a suboptimal arm with gap , how do you show that it is pulled about times at most, and what does this give for and ?
Next in Reinforcement learning: A duelling DQN has a value stream and an advantage stream. For one state, and for three actions. Compute using (a) , (b) and (c) . Why is (a) not identifiable, and what do (b) and (c) fix?