TL;DR
Most reinforcement learning methods learn only the average of the future reward from a state, which is the value function. Distributional reinforcement learning learns the full spread of possible returns: the chance of each total the agent might collect. The mean is still there, so nothing is lost, and the extra detail gives a stronger learning signal and a direct view of risk.
Builds on: Bellman Equation, Discounted Return, Probability Mass Function, Softmax · Leads to: risk-aware control and the categorical and quantile families of return models
Where it's used
Playing video games from pixels. The 2017 C51 agent, named for its 51 fixed support points, learned the return distribution with a deep network and reached strong results on the Atari suite. It extended the Deep Q-Network design by replacing a single output per action with a distribution over 51 values.
Robots and self-driving decisions. A controller that must avoid rare disasters cares about the lower tail of the return, not only the average. A learned distribution lets the designer ask for the chance that a plan ends badly, which an average hides. The worked example below uses this case.
Trading and resource control. A strategy that is good on average may still have a long bad tail. Distributional models let a practitioner compare two strategies by their risk profile, for example by the probability of losing more than a set amount.
How it works
Take one state with one action. The agent receives a reward and then moves to a state . From it always collects a fixed reward of 2 and then the episode ends. Use discount factor . At the reward is 0 or 4, each with probability one half.
- Look at the immediate reward at . It is 0 with probability one half and 4 with probability one half. Check: the two probabilities add to 1.
- Look at the next state . Its return is always 2, because the reward is fixed and nothing follows. Check: a state with no randomness has a one-point distribution.
- Combine them with the discount. The return from is the reward plus times the return from . If the reward is 0, the return is . If the reward is 4, the return is . Each case has probability one half. Check: the two outcomes 1 and 5 come from the two rewards.
- Check the mean. The average of the return is . The ordinary Bellman equation gives the same answer: the average immediate reward is , and the discounted value of adds , so the value of is . Check: both routes give 3.
- Read the result. The return from is 1 or 5, each with probability one half. The mean is 3, but the average alone does not show that the return is always one of two values.
flowchart LR x["state x"] -->|"prob 1/2, reward 0"| o1["return 1"] x -->|"prob 1/2, reward 4"| o5["return 5"]
Distributional RL keeps the whole picture: at the two possible returns and their probabilities.
The math
Definition
The return from time is , a random variable because the rewards and transitions are random. The return distribution of a policy in state is the distribution of when the episode starts in and actions follow . Write it , a random variable whose law is the return distribution.
is the random variable that results from starting in and following . Its probability law is the distribution over possible returns. Its expected value is the ordinary value function:
Step 3 in symbols: the distributional Bellman equation
The return satisfies a one-step recursion: the immediate reward plus times the return from the next state. Write , and . Then
where means equal in distribution: the two sides have the same probability law, though they need not be equal sample by sample. In the walkthrough, the left side is the return from , and the right side is the reward plus half the return from .
Step 4 in symbols: the mean recovers the Bellman equation
Take the expectation of both sides of the equation above. The expectation of a sum is the sum of expectations, so , which is the ordinary Bellman expectation equation. So a distributional method contains the usual one. This is why the mean in step 4 of the walkthrough matched the value 3.
The distributional operator behind the equation
Define the operator that maps a return distribution to the distribution of . Under the maximal Wasserstein distance between distributions, is a contraction with factor , the same rate as the ordinary Bellman operator. The argument in the 2017 paper uses the Wasserstein distance, and it guarantees that repeated application converges to a unique return distribution. This is the distributional counterpart of the convergence in Dynamic Programming.
Step 5 in symbols: the categorical model
A computer cannot represent an arbitrary distribution, so C51 fixes support points, or atoms, evenly spaced from to , with spacing . A network outputs scores for each action, and a Softmax turns them into probabilities that sum to 1. The model is
a probability mass function over the atoms, where puts all its mass on . Only the probabilities are learned; the atoms are fixed.
Projecting the target onto the atoms
After a Bellman step, the shifted atoms may fall between grid points or outside . The projection moves each piece of probability to the two nearest atoms. Clip , and let , with and . Then each target atom with mass adds
If is a whole number, then and all the mass goes to that atom. The result is a distribution over the atoms, and the network is trained to match it, usually with the cross-entropy loss between and the predicted .
Worked examples
- From state the agent gets reward 1 with probability one half, and reward 0 with probability one half. Then the episode ends.
- The return from is just the reward. So it is 1 with probability one half and 0 with probability one half.
- The mean is , which is the value of .
- The variance is . Check: each deviation from the mean is 0.5, so its square is 0.25.
- Interpretation: the mean 0.5 is the value, and the variance 0.25 is the spread that the value alone does not show.
Use atoms , so , and . Let the next-state distribution be . The reward is and .
- Compute the shifted atoms : they are . All lie inside , so no clipping is needed.
- Convert to grid positions . These are .
- Atom has and . It is a whole number, so all goes to atom 1.
- Atom has and . It splits between atoms 1 and 2: to atom 1 and to atom 2.
- Atom has and . All goes to atom 2.
- Atom has and . It splits: to atom 2 and to atom 3.
- Atom has and . All goes to atom 3.
- Add up the masses by location: the atom at position 1 gets ; the atom at position 2 gets ; the atom at position 3 gets . The total is 1.0. Check: the masses add to 1, as they must.
- Check the mean. Before projection, the next-state mean is , so the target mean is . After projection, the mean is . Check: the mean is preserved here because no clipping happened.
An autonomous car at a junction can merge now or wait. The return for each action, in reward points, has this distribution.
- Merge: a return of 10 with probability 0.8, and a return of with probability 0.2.
- Wait: a return of 3 with probability 1.
- Compute the mean of merging: .
- Compute the mean of waiting: it is 3.
- Compare the means: 6.8 is larger than 3, so a mean-only agent merges.
- Look at the distribution of merging instead: one outcome in five is a negative return.
- Check the risk: merging has a negative return with probability , and waiting has a negative return with probability .
- Interpretation: the mean prefers merging, but the distribution shows a one-in-five chance of a loss. A designer who weights losses more than gains can choose waiting, and only the distributional model makes this trade-off visible.
Try it: for each action, what is the probability that the return is at least 5? Answer: merging gives 0.8, since only the return of 10 reaches 5. Waiting gives 0, since its return is 3.
Common mistakes and tradeoffs
It is tempting to think a distributional agent learns a different optimal policy; in fact its mean still satisfies the ordinary Bellman equation, so the value of each action is unchanged. What changes is the information the agent learns, and the way the network is trained. Risk-aware decisions use the extra information; mean-only decisions do not need it.
It is tempting to think the return distribution is the same as the reward distribution; in fact the return adds up discounted rewards across many steps, so its spread is usually larger and its shape can differ a great deal from any single reward.
It is tempting to read as equality of values; in fact it says the two sides have the same probability law. The random values on each side can differ on any single sample.
It is tempting to think the atoms are learned locations; in fact the atoms are a fixed grid chosen in advance, and only their probabilities change. A poor choice of and clips real returns and loses information, so the bounds need a rough guess of the return range.
Use distributional learning when the spread matters: risk, rare large losses, or when the extra signal helps a deep network learn. Do not use it when only the average return matters and compute is tight, because it needs outputs per action and a projection step. Alternatives include a single value per state, which is cheapest, and quantile models, which learn points on the return's cumulative distribution instead of a fixed grid.
History
Before 2017 most deep reinforcement learning used single values, as in Q-Learning and the Deep Q-Network of 2015, and the return distribution was mostly studied in theory. In 2017 Marc Bellemare, Will Dabney and Rémi Munos published "A Distributional Perspective on Reinforcement Learning", which proved that the distributional Bellman operator is a contraction and introduced the categorical C51 agent with its projection step. C51 showed large gains on Atari games, and the paper made the distribution a practical object for deep networks. The idea caught on because it gives the agent more to learn from at no loss to the mean, and because it provides a direct handle on risk.
Recap
- The return from a state is a random variable, and its distribution is the return distribution.
- Its mean is the ordinary value, so the usual Bellman equation is still inside the distributional one.
- The distributional Bellman equation holds in distribution, and it is a contraction under the Wasserstein distance.
- C51 approximates the distribution on a fixed grid of atoms and projects each Bellman target back onto that grid.
- The distribution shows risk that the mean hides, which is why it matters for control.
Read next: Deep Q-Network for the network that C51 extends, Temporal-Difference Learning for the bootstrapped updates that the projected target builds on, and Kullback–Leibler Divergence for the divergence sometimes used to compare distributions.
Check yourself
QuestionA state's return is 2 with probability 0.5 and 6 with probability 0.5. What is its value?Show answer
The value is the mean, .
QuestionWith atoms at 0, 1 and 2, a target atom has mass 0.6 and shifted position 1.25. How much mass goes to the atoms at 1 and 2?Show answer
The position 1.25 lies between atoms 1 and 2, so the mass splits. Atom 1 gets and atom 2 gets . Together they make 0.6, as they must.
QuestionWhy does the distributional Bellman equation use rather than an ordinary equals sign?Show answer
The two sides are random variables that have the same probability law but generally take different values on each sample. Only the distributions must agree, so equality in distribution is the correct statement.
QuestionTwo actions have the same mean return, but one has a much wider spread. Why might a distributional agent prefer the narrower one in a safety-critical task?Show answer
The wider action has more probability in its bad outcomes, so its chance of a harmful return is higher even though the mean is the same. A distributional agent can see that tail and prefer the narrower action, while a mean-only agent cannot tell them apart.
QuestionIn C51, why are the atom locations fixed while the probabilities are learned?Show answer
Fixing the atoms gives a common grid on which every return distribution can be represented and compared, so the network only has to learn how much probability goes to each location. Learning the locations too would make the representation harder to train and compare.