Sampling as Optimization via Random Perturbations

This direction is split into other directions: optimization-based sampling. Its last version stays readable and citable here.

Version 1 of 132 papers47 conceptsfrozen 2026-10-04

In probabilistic machine learning, we often face a choice between two fundamental tasks: optimization (finding the single best configuration) and sampling (exploring the full distribution of likely configurations). Optimization is generally faster and more scalable, benefiting from decades of research into efficient solvers and parallel hardware. Sampling, typically performed via Markov Chain Monte Carlo (MCMC), is often slow, sequential, and prone to getting stuck in local modes.

A powerful research direction has emerged to bridge this gap by reframing sampling as a discrete optimization problem. By injecting specific types of random noise into a model's energy function and then finding the "best" solution, we can generate exact or near-exact samples from complex distributions.

The Gumbel-Max Foundation

The core of this approach is the Gumbel-Max trick. To sample from a discrete categorical distribution with probabilities $\pi_1, \dots, \pi_k$, one could calculate the cumulative distribution and draw a uniform variable. Alternatively, as Zoubin Ghahramani notes in Scalable Discrete Sampling as a Multi-Armed Bandit Problem, you can add independent Gumbel-distributed noise to the log-probabilities of each state and simply pick the index that maximizes the result.

Mathematically, if $g_i$ are i.i.d. Gumbel random variables, then: $$z = \arg\max_i (\log \pi_i + g_i)$$ is a sample from the original distribution. This transformation is profound because it turns a probabilistic selection into a deterministic search. This shift allows researchers like Shirui Zhao and Marian Verhelst to design specialized hardware that replaces expensive exponential and division operations with simple maximum value searches, as described in MC2A: Enabling Algorithm-Hardware Co-Design for Efficient Markov Chain Monte Carlo Acceleration.

Scaling to Structured Spaces

While the Gumbel-Max trick works for simple lists of items, modern problems involve structured outputs—like predicting a sequence of words, a 3D molecular structure, or a graph matching. In these cases, the number of possible configurations is exponential, making it impossible to add noise to every single state.

The Perturb-and-MAP framework generalizes the Gumbel-Max trick to these high-dimensional spaces. Instead of perturbing every state, we add noise to the local "potentials" or parameters of the model. Subhransu Maji, Tamir Hazan, and Tommi Jaakkola demonstrate in On Sampling from the Gibbs Distribution with Random Maximum A-Posteriori Perturbations that by perturbing these local components and solving for the Maximum A-Posteriori (MAP) assignment, we can effectively sample from complex Gibbs distributions.

This approach turns the sampling problem into a series of optimization tasks. This is particularly useful for distributions with many sharp peaks where MCMC would struggle to move between modes. By "shaking" the energy landscape with noise, the optimizer is forced to land in different high-probability regions across different runs.

Leveraging Black-Box Solvers

One of the most practical advantages of this direction is that it allows the use of "black-box" optimization solvers. If you have a fast solver for a specific problem—like an Integer Linear Programming (ILP) solver for scheduling or a Max-Product message-passing algorithm for image segmentation—you can turn it into a sampler.

In Exact Sampling with Integer Linear Programs and Random Perturbations, Ashish Sabharwal and Stefano Ermon introduce GumbelMIP, which uses ILP solvers to perform exact sampling in high-treewidth models that were previously considered "un-samplable." Similarly, Miguel Lazaro-Gredilla and colleagues at Vicarious AI show in Perturb-and-max-product: Sampling and learning in discrete energy-based models that replacing sequential MCMC with parallel message-passing can achieve orders-of-magnitude speedups.

Beyond Simple Sampling

The "sampling-as-optimization" paradigm has expanded into various specialized domains:

  • Sequence Generation: Wouter Kool and Max Welling developed Stochastic Beam Search in Stochastic Beams and Where To Find Them, applying the Gumbel-Top-$k$ trick to sample sequences without replacement, enabling the construction of low-variance statistical estimators.
  • Decision Making: In Racing Thompson, Jun Zhu and Yichi Zhou use the Gumbel-Max trick to make Thompson Sampling computationally feasible for complex, non-conjugate priors by finding the maximum of a sample rather than characterizing the entire posterior.
  • Differentiable Matching: Hedda Cohen Indelman and Tamir Hazan combine Gumbel noise with differentiable projection operators in Learning Latent Partial Matchings with Gumbel-IPF Networks to learn correspondences between objects in an end-to-end deep learning framework.

Theoretical Guarantees

While the intuition of "shaking the landscape" is compelling, the mathematical rigor is provided by measure concentration results. Francesco Orabona and Anand D. Sarwate proved in On Measure Concentration of Random Maximum A-Posteriori Perturbations that expectations in high-dimensional models can be estimated with surprisingly few samples using these methods. This theoretical foundation ensures that the samples generated via optimization are not just diverse, but statistically representative of the underlying distribution.

Papers in this version

History & citationVersion 1 · 2026-10-04

Split into other directions · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_sampling_as_optimization_via_random_pert_f4d8e747,
  title = {Sampling as Optimization via Random Perturbations},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/sampling-as-optimization-via-random-perturbations/rdr_f4d8e747229f4339bf2f92d27101a53d},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-23},
}

This exact version (version 1, frozen text):

@misc{lacuna_sampling_as_optimization_via_random_pert_f4d8e747_v1,
  title = {Sampling as Optimization via Random Perturbations},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/sampling-as-optimization-via-random-perturbations/rdr_f4d8e747229f4339bf2f92d27101a53d/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-23},
}