In modern machine learning, we typically treat Stochastic Gradient Descent (SGD) as a tool for finding a single "best" set of parameters. We run the algorithm, it converges to a point estimate, and we move on. However, in many high-stakes applications—like finance, healthcare, or reinforcement learning—a point estimate is not enough. We need to know how certain we are. We need "error bars" or confidence intervals.
The challenge is that traditional statistical inference requires looking at the entire dataset at once to calculate variances. In a streaming or large-scale setting, we cannot afford to store the data or the history of the model's updates. This has led to a new frontier: online statistical inference, where we estimate the uncertainty of a model's parameters at the same time we are learning them.
The Foundation: Asymptotic Normality
The reason we can perform inference on SGD at all is a property called asymptotic normality. While the individual steps of SGD are noisy, the average of those steps is remarkably well-behaved.
Xi Chen, Xin T. Tong, and Yichen Zhang demonstrated in Statistical Inference for Model Parameters in Stochastic Gradient Descent that under certain conditions, the parameters learned by SGD follow a normal distribution centered around the true value. This is often achieved through Polyak-Ruppert averaging, where we track the running average of all iterates. As Xiang Li and colleagues show in their work on Polyak-Ruppert Averaged Q-learning, this averaging isn't just a stabilization trick; it’s the engine that allows us to apply the Central Limit Theorem to optimization.
The Sandwich Estimator Challenge
To build a confidence interval, we need the covariance matrix of our parameters. In classical statistics, this is often a "sandwich" matrix: $H^{-1} \Sigma H^{-1}$, where $H$ is the Hessian (the curvature of the loss) and $\Sigma$ is the covariance of the gradients (the noise).
Calculating this sandwich matrix is computationally expensive. A model with $d$ parameters has a $d \times d$ covariance matrix, making a naive calculation $O(d^3)$. To make this work in real-time, researchers have developed recursive plug-in estimators. Instead of recomputing the Hessian from scratch, Xi Chen and Wei Biao Wu in Online Covariance Matrix Estimation in Stochastic Gradient Descent propose a "Hessian-free" method that updates the covariance estimate incrementally with $O(d^2)$ complexity. This allows the uncertainty estimate to evolve alongside the parameters.
Estimating Variance from the Trajectory
If we don't want to explicitly track the Hessian, can we estimate uncertainty just by looking at how much the SGD iterates "wiggle"?
This is the intuition behind batch-means estimators. By dividing the sequence of SGD iterates into blocks (batches) and looking at the variance between these blocks, we can approximate the long-run variance.
- Non-overlapping batches: Jiaqi Li and Johannes Schmidt-Hieber show in Asymptotics of Stochastic Gradient Descent with Dropout Regularization in Linear Models that this can be done recursively with a constant memory footprint.
- Overlapping batches: For more complex data, Abhishek Roy and Krishnakumar Balasubramanian demonstrate in Online covariance estimation for stochastic gradient descent under Markovian sampling that overlapping batch-means can handle data that is correlated over time (Markovian), which is common in real-world sensor streams.
Inference in Reinforcement Learning
This direction is particularly vital for Reinforcement Learning (RL). In RL, we use Temporal Difference (TD) learning to estimate the value of a policy. Because TD learning is essentially a stochastic approximation algorithm, it suffers from the same uncertainty issues as SGD.
Yuting Wei, Alessandro Rinaldo, and Weichen Wu in Statistical Inference for Temporal Difference Learning with Linear Function Approximation provide a framework for constructing confidence intervals for these value estimates. By using an online plug-in estimator, they allow an agent to not only estimate how "good" a state is but also how much it should trust that estimate based on the data it has seen so far.
High-Dimensional and Implicit Methods
As we move to high-dimensional settings where the number of features might exceed the number of observations, standard SGD becomes unstable. Lan Luo and colleagues addressed this in Statistical Inference in High-dimensional Generalized Linear Models with Streaming Data by introducing the Online Debiased Lasso, which uses summary statistics to provide valid p-values for predictors in a stream.
Similarly, to handle the inherent instability of noisy gradients, Yoonhyung Lee and Joong-Ho Won explored implicit SGD in Statistical inference with implicit SGD. They showed that by using proximal updates, one can maintain the stability of the algorithm while still extracting the necessary Fisher information to build reliable confidence intervals.
Summary of the Intuition
The shift from "optimization" to "online inference" relies on three pillars:
- Averaging: Using Polyak-Ruppert averaging to ensure the parameters converge to a normal distribution.
- Recursion: Updating the covariance (the "error bars") incrementally so we never have to store the full history of the data.
- Trajectory Analysis: Using the "wiggles" of the algorithm itself as a proxy for the underlying noise in the data.
By integrating these, we transform SGD from a simple search tool into a rigorous statistical instrument capable of quantifying its own uncertainty in real-time.