- The paper presents novel expected linear-time algorithms, QuickVaR and QuickDivergence, to compute VaR, CVaR, and related risk measures without relying on sorting.
- The methodology leverages element-wise separable capacity functions and polymatroid optimization to efficiently handle large discrete distributions.
- Numerical results and case studies demonstrate order-of-magnitude runtime improvements, making the methods practical for risk-sensitive applications.
Computing Monetary Risk Measures in Linear Time: An Expert Overview
Introduction and Motivation
Monetary risk measures—including Value-at-Risk (VaR) and Conditional-Value-at-Risk (CVaR)—are foundational tools for incorporating risk-averse decision-making in domains such as finance, robotics, and reinforcement learning. Traditional algorithms for computing these measures, especially on large discrete random variables, have Ω(nlogn) complexity due to reliance on sorting. This computational bottleneck hampers modern applications where risk measures are repeatedly evaluated within scalable machine learning or operational systems.
The discussed paper introduces novel, expected-linear-time algorithms for computing a broad class of risk measures—including VaR, CVaR, and related φ-divergence-based risk measures—over discrete random variables of arbitrary size. The central innovations are the QuickVaR and QuickDivergence algorithms, which avoid explicit sorting, resulting in order-of-magnitude empirical improvements in runtime without sacrificing accuracy.
Risk Measures and Theoretical Foundations
Monetary risk measures generalize the expectation to capture risk aversion. VaR at confidence level α is defined as the largest value such that the probability of outcomes below it does not exceed α:
VaRα[x~]=max{τ:P(x~<τ)≤α}
CVaR (also known as Expected Shortfall) as well as TVaR and EVaR, belong to a class of coherent, law-invariant risk measures expressible as optimization problems over the probability simplex, frequently involving additional convex constraints, e.g., via φ-divergences.
A central theoretical insight is that for coherent, comonotonic risk measures, the risk computation reduces to linear optimization over (normalized) polymatroids with a particular structure—specifically, those induced by "element-wise-separable" (EWS) capacity functions. These structural properties are harnessed for linear-time optimization.
Figure 1: A comparison of risk measure values for a normal distribution (mean $0$, standard deviation $1$) as a function of the risk level α. CVaR and TVaR provide increasingly conservative risk estimation compared to classical VaR, giving tighter lower bounds for tail behavior.
QuickVaR: Linear-Time Value-at-Risk Computation
The canonical approach to computing VaR (and quantiles with general weights) requires sorting, resulting in Ω(nlogn) runtime. The QuickVaR algorithm presented in the paper generalizes the quickselect algorithm to handle arbitrary probability weights, computing VaR in expected φ0 time.
QuickVaR operates recursively:
- It partitions the vector into elements less than, equal to, or greater than a randomly selected pivot.
- Probability mass is accumulated for each partition, permitting efficient identification, via adapted recursion, of the index satisfying the VaR criterion:
φ1
- The correctness and expected linear-time complexity are established using analogous arguments as for randomized quickselect, extended to weighted data.
Notably, QuickVaR extends naturally to measures like the weighted median but is uniquely correct for non-uniform weights and non-unique quantiles.
QuickDivergence: Linear-Time φ2-divergence Risk Measures
Many important risk measures—especially those arising in robust optimization and reinforcement learning—fall into the φ3-divergence family. This class includes CVaR, EVaR (entropic), and TVaR (total variation), all of which can be written as linear function minimization over subsets of the probability simplex subject to divergence-related constraints.
QuickDivergence exploits the structural observation that, for EWS polymatroid formulations, the classical greedy optimization can be performed without sorting, leading to φ4 algorithms:
- The computation is reduced to evaluating the optimal allocation of probability mass according to element-wise thresholds, which QuickVaR efficiently determines.
- The paper proves that the EWS property is met for CVaR and TVaR (with explicit capacity functions), thus allowing both to be computed in linear time.
Numerical Results
Empirical evaluation confirms substantial speedups for the proposed QuickVaR and QuickDivergence algorithms relative to sorting-based baselines across both synthetic and realistic data regimes.

Figure 2: Empirical runtime of linear-time algorithms compared to standard sorting-based methods for uniform (left) and sparse (right) distributions, with φ5 confidence bands over repeated runs. Linear algorithms scale efficiently and increasingly outperform φ6 approaches as φ7 grows.
- Both VaR and CVaR computations achieve order-of-magnitude runtime reductions at large φ8.
- The improvements hold even for modestly sized domains, making these techniques practical for repeated application in high-frequency or high-volume settings.
- Tables and additional case studies (e.g., financial portfolio scenarios) reinforce the practical dominance of the proposed algorithms for all tested settings.
Theoretical and Practical Implications
This work decisively resolves a long-standing computational bottleneck in evaluating key risk measures for large-scale discrete distributions. Theoretical contributions include:
- Novel extension of randomized selection to the risk aggregation setting.
- Polymatroidal methods tailored for EWS capacities common to important risk measures.
- General framework extendable to new risk measures, provided they admit suitable decompositions.
Practically, the algorithms directly enable scalable deployment of risk-aware optimization and RL methods, particularly in AI domains that require frequent evaluation of complicated risk functionals as part of learning or planning loops. The resulting reductions in runtime can translate to substantially more efficient training and inference for risk-sensitive models in finance, robotics, and resource allocation.
Future Directions
Natural avenues for further research include:
- Extending linear-time algorithms to other risk measures not covered by current EWS structure, such as EVaR or expectiles.
- Exploring implications for continuous-domain problems via discretization or specialized optimization.
- Leveraging these techniques within end-to-end differentiable pipelines for risk-averse learning.
Conclusion
The introduction of QuickVaR and QuickDivergence provides expected linear-time methods for exactly computing VaR, CVaR, and TVaR on discrete finite spaces, eliminating the need for sorting. Theoretical and empirical evidence supports significant computational acceleration, with clear benefits for large-scale, risk-sensitive AI and optimization tasks. Broader application and algorithmic generalization remain compelling topics for future work.