Probabilistic Programs with Stochastic Conditioning

David Tolpin, Yuan Zhou, Tom Rainforth, Hongseok Yang

The Challenge of "Messy" Data in Probabilistic Programming

Standard probabilistic programming systems are built around deterministic conditioning: a model observes a specific, fixed data point (e.g., "the temperature is 22.5°C") and updates its beliefs accordingly. However, real-world data is rarely this clean. Often, data is restricted, aggregated, or inherently uncertain:

  • Privacy Constraints: Hospitals might only release summary statistics (like the mean and variance of patient symptoms) to protect privacy, rather than individual health records.
  • Decoupled Data: You might have access to a set of weather observations and a separate set of commute times, but lack the direct pairing of which commute happened on which specific day.
  • Stochastic Planning: In robotics or logistics, agents often need to condition on a distribution of possible future states (such as the probability of a road closure) rather than a single guaranteed outcome.

Existing probabilistic programming systems struggle with these scenarios. While researchers can technically use "nested" probabilistic programs to handle aggregated or uncertain data, these workarounds are computationally expensive, difficult to implement, and often break the gradient-based inference methods that make modern machine learning fast.

A New Approach: Stochastic Conditioning

To solve this, the authors introduce stochastic conditioning, a powerful generalization that allows models to be conditioned directly on marginal distributions or summary statistics.

Instead of relying on the standard likelihood of a single point $p(y|x)$, the authors define the likelihood of observing a distribution $D$ (with density $q$) given parameters $x$ using a type II geometric integral:

$$p(y \sim D|x) = \exp \left( \int (\log p(y|x)) q(y) dy \right)$$

Why this specific formula?

  1. The KL Divergence Connection: Maximizing this geometric likelihood is mathematically equivalent to minimizing the Kullback–Leibler (KL) divergence between the observed distribution $q(y)$ and the model's predicted distribution $p(y|x)$. The model is fundamentally trying to "match" the shape of the observed distribution.
  2. Computational Efficiency: The log-likelihood of this expression can be easily estimated using simple Monte Carlo sampling: $\log p(y \sim D|x) \approx \frac{1}{N} \sum \log p(y_i|x)$. This resembles the "subsampling" techniques used for massive datasets, making it fully compatible with fast, modern inference algorithms like Stochastic Gradient Hamiltonian Monte Carlo (SGHMC).

The "Aha" Moment: Geometric vs. Arithmetic Averaging

A common intuitive mistake when trying to condition on a distribution is to simply average the probabilities arithmetically (i.e., $\int p(y|x) q(y) dy$). The authors demonstrate that this arithmetic approach is overly sensitive to outliers and often fails to recover the true distribution parameters. Their proposed "geometric" approach is significantly more robust.

Comparison of the proposed geometric approach (Definition 3) versus a naive arithmetic average (Definition 4).

Furthermore, unlike nested programs, models utilizing stochastic conditioning remain entirely differentiable. This allows researchers to leverage powerful gradient-based inference engines (like NUTS or HMC), which are often orders of magnitude faster than basic Metropolis-Hastings algorithms.

Empirical Validation

The authors evaluated their approach across three distinct case studies, proving its versatility and performance:

  1. New York State Population (Summary Statistics): Using a historical dataset of 804 municipalities, the model was conditioned only on summary statistics (mean, standard deviation, and quantiles) rather than the raw data. Remarkably, the authors inferred 95% confidence intervals that were tighter than the original 1983 study that had access to the full dataset.
  2. Weather Forecast Accuracy (Decoupled Data): In a synthetic dataset where weather conditions and trip durations were observed separately as marginal distributions, the model successfully produced informative posteriors even without knowing which weather matched which trip.
  3. The Sailing Problem (Stochastic Planning): A classic benchmark where a boat must navigate a lake with changing wind directions. The "observation" is the random walk distribution of the wind.
The Sailing Problem benchmark, illustrating the lake grid and points of sail used for stochastic planning.

Across these tasks, stochastic conditioning yielded massive speedups. For example, in the decoupled weather/commute model, the stochastic approach reached the same effective sample size 125x faster than the previous state-of-the-art nested conditioning method (4.1 seconds vs. 520 seconds).

Limitations and Future Directions

While highly effective, the paper notes a few limitations. The method requires a technical "uniform-bound condition" for the normalization constant to remain finite. While common distributions (like Normals with fixed variance) satisfy this, some edge cases do not.

Additionally, while the authors provided a reference implementation in Infergo, stochastic conditioning needs to be integrated into mainstream probabilistic programming languages like Pyro, Stan, or Turing to achieve widespread adoption. Future work will also need to explore how this method scales with extremely high-dimensional or non-parametric observed distributions where simple Monte Carlo sampling might lose efficiency.

Summary updated

BibTeX
@inproceedings{tolpin2021probabilistic,
  author = {David Tolpin and Yuan Zhou and Tom Rainforth and Hongseok Yang},
  title = {{Probabilistic Programs with Stochastic Conditioning}},
  booktitle = {International Conference on Machine Learning},
  year = {2021},
  url = {https://openreview.net/forum?id=tXweLT3n57},
}
Figure