Comparing Direct and Indirect Temporal-Difference Methods for Estimating the Variance of the Return

Craig Sherstan, Dylan R. Ashley, Brendan Bennett, Kenny Young, Adam White, Martha White, Richard S. Sutton

Abstract

In reinforcement learning (RL), agents typically estimate the expected return to guide decision-making. However, for risk-sensitive applications, understanding the variance of these returns is equally critical. Traditional "indirect" methods estimate the first and second moments separately to derive variance, a process prone to instability and negative estimates. This paper proposes Direct Variance Temporal-Difference (DVTD), a novel approach that learns variance directly using a sequence of two TD learners. By utilizing the squared TD error of a value estimator as the reward signal for a variance estimator, DVTD simplifies the learning process and enhances robustness. Empirical results across various Markov Decision Processes (MDPs) show that DVTD outperforms indirect methods in stability, hyperparameter sensitivity, and function approximation.

Introduction

Reinforcement learning agents are generally designed to maximize the expected return. While effective for many tasks, the average return does not capture the risk or uncertainty inherent in stochastic environments. In domains like autonomous systems or finance, estimating the variance of the return is essential for safety and reliability.

Historically, variance estimation has relied on the identity $Var[X] = E[X^2] - (E[X])^2$. This indirect approach requires tracking two separate moving targets: the mean and the mean of the squares. Small errors in the mean estimate can lead to significant instabilities or even mathematically impossible negative variance values. The researchers at the RLAI Lab at the University of Alberta address this by introducing a "direct" method that treats variance itself as a value to be learned through standard TD updates.

The Direct Variance TD (DVTD) Method

The core innovation of this work is the Direct Variance TD (DVTD) algorithm. The authors derive a Bellman-style recursive equation for variance, allowing it to be estimated using standard RL machinery.

The architecture consists of two TD learners in series:

  1. The Value Learner: A standard TD agent that estimates the expected return and produces a TD error ($\delta_t$).
  2. The Variance Learner: This agent uses the squared TD error ($\delta_t^2$) from the first learner as its reward signal and the squared discount factor ($\gamma^2$) as its discount rate to estimate the variance.
Comparison of the Direct Method (DVTD) and the indirect Variance TD (VTD) architectures.

This decoupling allows the variance learner to benefit from established RL techniques like eligibility traces ($\lambda$) and off-policy learning without additional complexity.

Experimental Evaluation

The authors tested DVTD against the traditional indirect Variance TD (VTD) method across three synthetic environments:

  • Chain MDP: A deterministic 4-state environment used to analyze sensitivity to learning rates (step-sizes).
  • Random MDP: A 5-state stochastic environment with random rewards and transitions to test performance under "messy" conditions.
  • Random Walk: A benchmark for testing linear function approximation, moving beyond simple tabular scenarios.

Key Results and Insights

The experiments highlighted several advantages of the direct approach:

1. Stability and Robustness

Indirect methods are highly sensitive to "step-size mismatch." If the mean and variance learners update at incompatible speeds, the variance estimate often spikes or becomes unstable. In contrast, DVTD remains robust across a wide range of hyperparameter settings.

2. Early Learning Performance

During the initial stages of learning, indirect methods often produce erratic estimates because the mean has not yet converged. DVTD, by learning from squared errors, tends to stay within a physically meaningful positive range and approaches the true variance more smoothly.

Learning curves for value and variance estimation in a 4-state chain MDP, comparing VTD and the Direct Method.

3. Function Approximation

In the Random Walk task, DVTD significantly outperformed VTD when using linear function approximation. The indirect method's reliance on subtracting two potentially biased estimates led to higher and more volatile errors compared to the direct method.

Conclusion

Direct Variance TD offers a mathematically elegant and practically robust alternative to traditional variance estimation in RL. By transforming variance estimation into a standard TD problem, it simplifies implementation and improves stability, particularly in the presence of function approximation. While the current formal proofs focus on tabular cases and acknowledge sensitivity to bias in the initial value learner, the empirical success of DVTD suggests it should become the preferred standard for risk-aware reinforcement learning.

Summary updated

BibTeX
@inproceedings{sherstan2018comparing,
  author = {Craig Sherstan and Dylan R. Ashley and Brendan Bennett and Kenny Young and Adam White and Martha White and Richard S. Sutton},
  title = {{Comparing Direct and Indirect Temporal-Difference Methods for Estimating the Variance of the Return}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2018},
}
Figure