Posterior Sampling for Continuing Environments

Wanqiao Xu, Shi Dong, Benjamin Van Roy

TL;DR

This paper introduces Continuing PSRL, the first extension of Posterior Sampling for Reinforcement Learning (PSRL) designed for infinite-horizon, non-episodic environments that scales to high-dimensional state spaces. By replacing complex, count-based resampling rules with a simple Bernoulli randomization scheme, the authors achieve a state-of-the-art Bayesian regret bound of $\tilde{O}(\tau S \sqrt{AT})$ while demonstrating superior performance in complex environments where traditional algorithms fail.

What Problem Does This Paper Address?

Most Reinforcement Learning (RL) exploration strategies, like Thompson Sampling, are designed for episodic environments—tasks with a clear beginning and end. In these settings, an agent typically updates its "beliefs" and picks a new strategy at the start of each episode.

However, many real-world problems are continuing environments (infinite horizon) with no natural resets. Exploring these is much harder. Previous attempts to adapt PSRL to continuing environments relied on tracking "visitation counts" for every state-action pair. While mathematically sound for simple problems, this approach is a non-starter for complex, high-dimensional environments (like robotics or video games) where an agent might never visit the exact same state twice. The challenge was to find a resampling mechanism that is both theoretically rigorous and practically scalable.

Methods

The authors propose a deceptively simple algorithm called Continuing PSRL. Instead of waiting for an episode to end or a state-count to double, the agent decides when to update its strategy based on a "coin flip":

  1. Random Resampling: At every single timestep, the agent flips a biased coin. With probability $p = 1 - \gamma$ (where $\gamma$ is a discount factor), the agent "resamples."
  2. Posterior Update: When a resample is triggered, the agent draws a new environment model from its posterior distribution (its current best guess of how the world works) and computes an optimal policy for that model.
  3. Discounted Planning: The agent optimizes for a $\gamma$-discounted objective. Crucially, the authors show that the undiscounted reward earned between these random resampling events is an unbiased estimate of the $\gamma$-discounted return.
  4. Scaling: Because this rule doesn't depend on state counts, it can be easily plugged into deep RL architectures. The authors demonstrate this by enhancing Bootstrapped DQN with their resampling scheme.

Datasets

The algorithm was evaluated on two versions of the RiverSwim environment, a classic RL benchmark that requires deep exploration to reach a high-reward state:

  • Tabular RiverSwim: A 6-state chain used to compare against traditional count-based baselines.
  • Continuous RiverSwim: A modified version where states are represented as high-dimensional raw pixel features, making it impossible for count-based methods to function.

Key Insights and Ideas

  • The Discount Factor as a Design Tool: In most RL, the discount factor $\gamma$ is considered a fixed part of the environment. Here, the authors treat it as a tunable hyperparameter that controls the agent's planning horizon and resampling frequency. By increasing $\gamma$ over time, the agent can plan for longer horizons as it becomes more confident.
  • Policy-Independent Resampling: Prior work used resampling triggers that depended on what the agent did (visitation counts). By making the trigger a simple, independent Bernoulli process, the authors simplified the mathematical analysis and removed the need for massive look-up tables.
  • Reward Averaging Time ($\tau$): The authors use $\tau$ to characterize environment complexity. It represents the time needed to accurately estimate a policy's average reward. This provides a more robust way to bound regret in continuing environments than previous metrics like "span."

Key Results

  • Theoretical Optimality: The authors prove a Bayesian regret bound of $\tilde{O}(\tau S \sqrt{AT})$. This matches the best-known bounds for episodic PSRL but applies to the much harder continuing setting.
  • Superior Scaling: In the high-dimensional "pixel" version of RiverSwim, Continuing PSRL (via Bootstrapped DQN) achieved sublinear regret, meaning it successfully learned the optimal policy. In contrast, standard exploration methods like $\epsilon$-greedy (vanilla DQN) incurred linear regret, failing to learn the task entirely.
  • Competitive Performance: In tabular settings, Continuing PSRL performed on par with the state-of-the-art TSDE algorithm, despite having a much simpler implementation.

Limitations and Future Work

  • Tabular Theory vs. Deep Practice: While the regret bounds are mathematically rigorous for the tabular case (finite states and actions), the application to deep RL (like DQN) remains empirical. A formal theoretical bridge for function approximation in continuing environments is still an open challenge.
  • Dependence on $S$ and $A$: The current regret bound still scales with the number of states ($S$) and actions ($A$). In truly massive environments, these terms might be too large, suggesting a need for bounds that depend on the complexity of the function approximator (e.g., neural network width/depth) instead.
  • Prior Knowledge: Like all Bayesian methods, the performance depends on having a reasonable "prior" distribution, which may not always be available in entirely unknown domains.

Summary updated

BibTeX
@misc{xu2022posterior,
  author = {Wanqiao Xu and Shi Dong and Benjamin Van Roy},
  title = {{Posterior Sampling for Continuing Environments}},
  year = {2022},
  eprint = {2211.15931},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.15931},
}
Figure