Inferensys

Glossary

Non-Stationary Bandit

A multi-armed bandit problem where the underlying reward distributions change over time, requiring the algorithm to continuously adapt and discount old observations.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
ADAPTIVE SEQUENTIAL DECISION-MAKING

What is Non-Stationary Bandit?

A non-stationary bandit is a reinforcement learning problem where the underlying reward probability distributions for each action change over time, requiring the algorithm to continuously adapt by discounting or forgetting obsolete historical observations.

A non-stationary bandit extends the classic multi-armed bandit framework to environments where the reward distributions are dynamic. Unlike stationary problems where the optimal arm remains constant, non-stationary settings—common in e-commerce and financial markets—require algorithms to detect concept drift and prioritize recent data. The core challenge is distinguishing genuine distribution shifts from random noise to avoid premature abandonment of a temporarily underperforming arm.

Standard algorithms are adapted using discounting mechanisms such as sliding windows or exponential decay of past rewards. For example, a discounted UCB or sliding-window Thompson Sampling applies a decay factor to older observations, ensuring the model's model freshness remains high. This continuous adaptation is critical for dynamic pricing and real-time recommendation systems where consumer preferences and competitor actions are in constant flux.

DYNAMIC ENVIRONMENTS

Key Characteristics of Non-Stationary Bandits

Non-stationary bandits address the critical real-world scenario where user preferences and environmental factors shift over time, requiring algorithms to continuously adapt and discount obsolete historical data.

01

Temporal Reward Distribution Shift

The fundamental property distinguishing non-stationary bandits: the expected reward for a given action changes over time. Unlike stationary problems where the optimal arm is fixed, here the underlying probability distribution drifts. This requires the algorithm to treat recent observations as more informative than older ones, effectively implementing a forgetting mechanism to track the moving target.

02

Discounting and Windowing Strategies

To adapt to drift, algorithms employ explicit mechanisms to weight recent data more heavily:

  • Sliding Windows: Only consider the last W observations, discarding older data entirely.
  • Exponential Discounting: Apply a decay factor γ (gamma) where the weight of an observation halves after a fixed number of steps.
  • Weighted Least Squares: In contextual settings like Discounted LinUCB, the linear model is fit by minimizing a weighted sum of squared errors, prioritizing recent context-reward pairs.
03

Abrupt vs. Gradual Change Detection

Non-stationarity manifests in two primary patterns:

  • Gradual Drift: The reward distribution changes slowly and continuously, like evolving user tastes over weeks. Discounted methods excel here.
  • Abrupt Switches: A sudden, discontinuous jump in rewards, such as a product going out of stock or a viral trend emerging. This often requires change-point detection algorithms that actively monitor for statistical breaks and reset the model's memory when a shift is detected, discarding all pre-change data.
04

Restless Bandit Formulation

A formal extension where the state of each arm evolves independently according to a Markov process, even when not selected. This models scenarios like user patience decaying over time or inventory depleting. The optimal policy must consider not just the immediate reward but how the underlying state of all arms is changing. Solving restless bandits is PSPACE-hard, making heuristic index policies like the Whittle index a common practical approximation.

05

Regret Against a Dynamic Oracle

Performance is measured by dynamic regret, which compares the algorithm's cumulative reward against a powerful oracle that can switch its chosen arm a limited number of times. This is a harder benchmark than static regret. Algorithms are often characterized by their regret bound as a function of T (time horizon) and S (number of environmental switches), with optimal algorithms achieving sublinear regret that scales with the total variation of the reward sequence.

06

Practical Deployment: Model Freshness

In production systems, non-stationarity is managed through online model retraining pipelines. A common pattern is the champion-challenger setup where a stable model serves traffic while a frequently retrained challenger is evaluated. Key metrics include model freshness—the time since the last update. For highly dynamic environments like flash sales or breaking news, freshness measured in minutes is critical to prevent serving stale, irrelevant recommendations.

NON-STATIONARY BANDITS

Frequently Asked Questions

Clear, technical answers to the most common questions about non-stationary bandit problems, their mechanisms, and their application in dynamic retail environments.

A non-stationary bandit is a sequential decision-making problem where the underlying reward probability distributions for each action change over time, violating the static assumption of classical bandit models. Unlike stationary bandits where the optimal arm remains constant, a non-stationary bandit requires the algorithm to continuously adapt by discounting or forgetting old observations that no longer reflect the current environment. The core mechanism involves applying a discount factor (gamma) or a sliding window to historical rewards, giving exponentially or strictly less weight to older data points. This ensures the model's estimates track the shifting true means rather than converging to a stale global average. In practice, this is implemented by modifying the update rule of algorithms like Thompson Sampling or UCB to decay the influence of past trials, effectively creating a moving estimate of each arm's value that can respond to abrupt changes or gradual drift in user preferences, seasonality, or market conditions.

ALGORITHMIC ADAPTATION COMPARISON

Stationary vs. Non-Stationary Bandit Algorithms

A technical comparison of stationary and non-stationary bandit algorithm variants, highlighting their mechanisms for handling changing reward distributions.

FeatureStationary BanditNon-Stationary BanditContextual Non-Stationary Bandit

Reward Distribution Assumption

Fixed over time

Changes over time

Changes based on context and time

Primary Objective

Identify single best arm

Track best arm as it shifts

Map context to optimal action dynamically

Discounting Mechanism

None or uniform weighting

Exponential decay or sliding window

Contextualized decay with feature weighting

Exploration Strategy

Decreasing over time

Sustained or adaptive

Context-dependent adaptive

Historical Data Weight

All data equally weighted

Recent data weighted higher

Contextually relevant data prioritized

Regret Bound Type

Static regret

Dynamic regret

Contextual dynamic regret

Typical Algorithm

UCB1, Thompson Sampling

Sliding-Window UCB, Discounted TS

LinUCB with forgetting, NeuralBandit

Sensitivity to Concept Drift

High degradation

Adapts to drift

Adapts and attributes drift to context

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.