Risk-Sensitive RL
CVaR, exponential utility and acting under risk preferences.
Expected return treats a sure 1.9 and a lottery paying 0.9 or 10.9 (mean 1.9) as equally good. Risk-sensitive RL optimizes something else: a variance penalty, an exponential utility, or the average of the worst outcomes. Each choice changes the mathematics. Exponential utility keeps a Bellman equation; CVaR is time-inconsistent and needs an augmented state; mean–variance optimization is NP-hard. This lesson develops all three with their theorems and conditions, and shows what a distributional agent does, and does not, optimize when it acts on risk.
What you’ll learn
- Define the variance-penalized, exponential-utility, VaR and CVaR criteria, check which axioms of coherent risk measures each satisfies, and compute them on small examples.
- Derive the multiplicative Bellman equation of exponential utility for finite-horizon total reward, its dual as KL-penalized robustness, and why discounting makes the optimal policy nonstationary.
- Prove the Rockafellar–Uryasev formula for CVaR, exhibit its time inconsistency, and describe the state augmentations proposed to restore dynamic programming, and which of them is exact.
- Derive the CVaR policy gradient, and explain why acting greedily on the CVaR of a learned return distribution at every step does not optimize the CVaR of the return.
Risk measures and their axioms
Artzner, Delbaen, Eber and Heath (1999) asked which properties a sensible risk measure should have. In the reward convention used here, a criterion is coherent if it is monotone ( always implies ), translation-equivariant (), positively homogeneous ( for ) and superadditive (: combining positions never looks riskier than the parts).
| Criterion | Monotone | Translation | Homogeneous | Superadditive |
|---|---|---|---|---|
| Mean | ✓ | ✓ | ✓ | ✓ |
| Mean–variance | ✗ | ✓ | ✗ | ✗ |
| Entropic | ✓ | ✓ | ✗ | ✗ (concave instead) |
| VaR | ✓ | ✓ | ✓ | ✗ |
| CVaR | ✓ | ✓ | ✓ | ✓ |
VaR's failure is not academic. Take two independent bets, each losing 100 with probability 0.04 and paying 0 otherwise. Each has , since its loss lies beyond the worst 5%. Their sum loses at least 100 with probability , so its is : by VaR, two harmless bets combine into a dangerous one, and a VaR-optimizer can hide risk by splitting it. CVaR counts the whole tail.
For one of these bets (lose 100 with probability 0.04, else 0), what is ?
Show the answer
-80
The worst 5% consists of the 4% at and 1% at 0, so . For the sum of two independent bets, the worst 5% holds 0.16% at and 4.84% at : , which is at least , as superadditivity requires.
Exponential utility: a multiplicative Bellman equation
Why it works. The exponential turns a sum into a product, . Given , the factor is a fixed positive number, so minimizing the product over the continuation policy is the same problem as minimizing , whatever rewards came before; by induction its value is . Among utility functions, only the linear and the exponential ones make preferences over the future independent of what has been collected (constant absolute risk aversion). The certainty equivalent is not the mean minus a variance penalty except approximately: on the lottery, against the approximation , while at the exact value is and the approximation, , is meaningless.
Discounting breaks stationarity. With , the same factorization gives : the continuation is an exponential-utility problem with risk parameter . Risk aversion effectively decays by per step, so optimal policies generally depend on time even in infinite-horizon discounted problems; carrying the current risk parameter in the state restores a recursion.
For any distribution of outcomes absolutely continuous with respect to the model , with density , the Gibbs variational principle states
To check it, minimize over densities with . Setting the derivative in to a constant gives , so , and substituting back gives the left side.
So a risk-averse exponential-utility agent behaves as if an adversary may tilt the model toward bad outcomes, paying per nat of KL divergence: the larger , the cheaper the distortion. This links risk sensitivity to robust MDPs (Robust MDPs & Sim-to-Real Transfer).
CVaR: dual forms and time inconsistency
is concave in , as is convex. Its derivative is , which vanishes where :
At that point , so
For the dual, the minimizing puts the maximal weight on the lowest outcomes until is used up, which is exactly the lowest of the distribution. Chow et al. (2015, Prop. 1) extend the dual to MDPs: the CVaR of a policy's cost equals its worst expected cost over adversarial perturbations of the transition probabilities whose product along any trajectory stays within a budget of , so a CVaR-optimal policy is also robust to such model errors.
CVaR's tail is a property of the whole return, and that makes it time-inconsistent. A two-stage example with : a coin first pays or ; then the agent chooses Safe, paying 1, or Risky, paying 0 or 3 with equal probability. A plan says what to do after each outcome of the coin:
| After | After | Total return | ||
|---|---|---|---|---|
| Safe | Safe | 1 or 3, each ½ | 1 | 2 |
| Safe | Risky | 1 (½), 2 (¼), 5 (¼) | 1 | 2.25 |
| Risky | Safe | 0 (¼), 3 (¾) | 1.5 | 2.25 |
| Risky | Risky | 0, 3, 2, 5, each ¼ | 1 | 2.5 |
The agent adopts the CVaR-optimal plan (Risky after ), the coin shows 0, and the agent now re-optimizes the of its remaining reward. What does it do?
- Risky, as planned, since the plan was optimal
- Safe: for the remaining reward alone, Safe has and Risky has 0, so the agent abandons its own plan
- It is indifferent between the two
- Risky, because Risky has the higher mean
Show the answer
B. Safe: for the remaining reward alone, Safe has and Risky has 0, so the agent abandons its own plan
Judged from time 0, Risky in this branch improves the tail of the total; judged from time 1, the same gamble is a bad bet for the remaining reward. That is time inconsistency: the optimal plan for static CVaR depends on the reward already collected, so it cannot be implemented by an agent that re-optimizes the same criterion from its current state, and it is history-dependent in the original state space.
Learning risk-sensitive policies
Derivation. Write CVaR in Rockafellar–Uryasev form, . By the envelope theorem the gradient is that of the objective at the fixed maximizer , and the likelihood-ratio trick gives ; dividing out gives the conditional form. Only tail trajectories count, each weighted by how far it falls below the VaR, so the update makes the worst trajectories less likely, the more so the worse they are.
import numpy as np
def cvar_policy_gradient(returns, scores, alpha=0.05):
"""returns: (N,) episode returns; scores: (N, d), each row the sum of grad log pi over one episode."""
var = np.quantile(returns, alpha, method="inverted_cdf") # empirical VaR_alpha
tail = returns <= var # about alpha * N worst episodes
weights = (returns - var) * tail # <= 0 inside the tail, 0 outside
return weights @ scores / (alpha * len(returns)) # ascend this direction to raise CVaRTamar et al.'s estimator. The empirical quantile makes it biased; they show it is consistent and prove that stochastic gradient ascent with it converges to a local CVaR optimum. With , 95% of the episodes contribute nothing, which is the method's practical cost: variance grows as shrinks.
What do distributional agents optimize when they act on risk? An agent like IQN with a CVaR distortion picks, at every step, the action whose learned has the best CVaR, and uses the same rule in its targets. In the two-stage example, the stage-2 state is the same after either coin outcome, so such an agent picks Safe both times and ends with , where 1.5 was achievable. Step-by-step CVaR-greedy control optimizes neither the static CVaR of the return nor, in general, a simple dynamic criterion. Two principled routes exist: optimize the static criterion on an augmented state (step 3), or adopt a nested (Markov) risk measure that applies a one-step coherent risk mapping, such as CVaR, at every step (Ruszczyński, 2010), time-consistent by construction but harder to interpret as a property of the return distribution.
Mean–variance looks easiest, since the variance has its own Bellman equation (Sobel, 1982). But optimizing it is hard: Mannor and Tsitsiklis (2011) show that in finite-horizon MDPs, finding a policy that maximizes the mean subject to a variance constraint is NP-hard in some cases and strongly NP-hard in others, and that randomized or history-dependent policies can be strictly better than deterministic Markov ones.
Risk-sensitive criteria are used where tails matter. In finance, deep hedging (Buehler, Gonon, Teichmann & Wood, 2019) trains hedging strategies for derivative portfolios with convex risk measures as objectives, under transaction costs and other frictions. In safety-critical control, CVaR appears as an objective and as a constraint (Constrained MDPs & Lagrangian Methods), and through its dual form it connects to robustness against model error.
Key takeaways
- Of the common criteria only CVaR (and the mean) is coherent: VaR can hide risk by splitting it, mean–variance can prefer a return that is worse in every outcome, and the entropic measure is concave but not positively homogeneous.
- Exponential utility of the finite-horizon total reward obeys the multiplicative Bellman equation , because the exponential factorizes; with discounting the risk parameter decays as , and its certainty equivalent equals a KL-penalized worst-case expectation.
- , attained at the VaR, and equals a worst-case reweighted expectation. Static CVaR is time-inconsistent: its optimal plan depends on the reward already collected, and exact dynamic programming needs a state augmented with the running total (the risk-level augmentation is exact only for evaluating a fixed policy).
- The CVaR policy gradient uses only tail episodes, weighted by their shortfall below the VaR; step-by-step CVaR-greedy distributional agents optimize neither static CVaR nor, in general, a simple dynamic criterion; and exact mean–variance optimization is NP-hard.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
Which of these criteria is a coherent risk measure?
- Value at risk,
- Mean minus variance,
- The entropic certainty equivalent
Show the answer
C.
CVaR is monotone, translation-equivariant, positively homogeneous and superadditive. VaR fails superadditivity (two harmless bets can combine into a dangerous one), mean–variance fails monotonicity and homogeneity, and the entropic measure is concave but not positively homogeneous.
Why does exponential utility of the total reward admit a Bellman equation, when the CVaR of the total reward does not?
- Because exponential utility is risk-neutral for small
- Because : past rewards only multiply the future's criterion by a positive constant, so the best continuation does not depend on them
- Because exponential utility is coherent
- Because CVaR cannot be estimated from samples
Show the answer
B. Because : past rewards only multiply the future's criterion by a positive constant, so the best continuation does not depend on them
Multiplicative separability means the continuation problem is the same whatever reward has been collected. For CVaR, whether the future's risk falls inside the worst of the total depends on what has been collected so far, so the optimal continuation depends on the past.
For a discounted exponential-utility objective , why is the optimal policy generally nonstationary?
- Because the continuation after one step is an exponential-utility problem with risk parameter : the effective risk aversion shrinks with time
- Because discounted problems never have stationary optimal policies
- Because the exponential is not monotone
- It is not: discounted exponential utility always has a stationary optimal policy
Show the answer
A. Because the continuation after one step is an exponential-utility problem with risk parameter : the effective risk aversion shrinks with time
Factor out the first reward: what remains is . The same state faced at a later time is faced with less risk aversion, so the best action can change with time. Including the current risk parameter in the state makes the problem Markov again.
In the CVaR policy gradient, which sampled episodes contribute to the update, and with what weight?
- All episodes, weighted by their return, as in REINFORCE
- Only the best fraction, weighted by how far they exceed the mean
- Only episodes at or below the estimated VaR, weighted by , so the update makes the worst episodes less likely, the more so the worse they are
- Only the single worst episode
Show the answer
C. Only episodes at or below the estimated VaR, weighted by , so the update makes the worst episodes less likely, the more so the worse they are
The gradient is : episodes above the VaR have weight zero, and tail episodes push their own probability down in proportion to their shortfall. Discarding of the data is why the estimator's variance grows as shrinks.
Further reading
- R. A. Howard & J. E. Matheson, "Risk-sensitive Markov decision processes", Management Science 18(7), 356–369 (1972).
- P. Artzner, F. Delbaen, J.-M. Eber & D. Heath, "Coherent measures of risk", Mathematical Finance 9(3), 203–228 (1999).
- R. T. Rockafellar & S. Uryasev, "Optimization of conditional value-at-risk", Journal of Risk 2(3), 21–41 (2000).
- Y. Chow, A. Tamar, S. Mannor & M. Pavone, "Risk-sensitive and robust decision-making: a CVaR optimization approach", NeurIPS (2015).
- A. Tamar, Y. Glassner & S. Mannor, "Optimizing the CVaR via sampling", AAAI (2015).