Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Inference when you can only simulate
Suppose a model of a galaxy, an epidemic or a particle detector can produce fake data for any parameter setting, but the probability of the real data under that setting cannot be computed. Simulation-based inference turns the simulator into a guessing game: run it many times with parameters drawn from the prior, and keep, or learn from, the runs that look like what was observed. The parameters that tend to reproduce the data form the posterior.
Simulation-based inference is used in cosmology, particle physics, epidemiology, neuroscience and population genetics, wherever the simulator is the model.
- 1. Simulation-based inference needs…
- 2. ABC keeps parameters whose simulations…
- 3. The result is…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Rejection ABC (Pritchard et al., 1999): draw θ from the prior, simulate x, keep θ if the distance between summaries s(x) and s(x_obs) is below a tolerance ε. As ε → 0 with sufficient summaries, the accepted θ follow the exact posterior.
- Summary statistics: low-dimensional features of the data. Sufficient summaries lose no information; insufficient ones give wider or biased posteriors.
- Regression adjustment (Beaumont et al., 2002): correct accepted θ by a regression on s − s_obs, allowing a larger tolerance.
- Neural posterior estimation (NPE): train q(θ | x) on simulated pairs by maximising log q(θᵢ | xᵢ); normalising flows or mixture networks are typical. The estimator is amortised: one training run serves every new dataset.
- Neural likelihood and ratio estimation: learn p(x | θ) or the ratio p(x | θ)/p(x) and use it inside MCMC.
- Validation: coverage of credible intervals over many simulated datasets, or simulation-based calibration (Talts et al., 2018).
- 1. Rejection ABC becomes exact as…
- 2. Amortised inference means…
- 3. Calibration is checked by…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.A simulator with a known answer
Exercise 1.
- Poisson counts y_t ~ Poisson(A e^(−k t)) at t = 0, …, 9, with uniform priors A in [5, 50] and k in [0.05, 0.5].
- Summaries: log of the total count and the mean arrival time Σ t y / Σ y. For this model they are sufficient statistics.
- The exact posterior on a 200 × 200 grid, used as ground truth.
Practice.
- Start from a model you can check: a version with a known likelihood, or simulated data with known parameters.
- Choose summaries carefully, or let a network learn them from the raw data.
- Always check calibration on held-out simulations before trusting intervals.
- Budget simulations: sequential methods focus simulations near the observed data.
- Tools: sbi (PyTorch), BayesFlow, ELFI and pyABC for ABC, swyft for ratio estimation.
from sbi.inference import NPE
from sbi.utils import BoxUniform
import torch
prior = BoxUniform(low=torch.tensor([5.0, 0.05]), high=torch.tensor([50.0, 0.5]))
theta = prior.sample((50_000,))
x = simulator(theta) # (50000, 10) counts
inference = NPE(prior=prior)
posterior = inference.append_simulations(theta, x).train()
posterior = inference.build_posterior()
samples = posterior.sample((2000,), x=x_obs)- 1. A widely used PyTorch package for neural SBI:
- 2. Before trusting SBI intervals, check…
- 3. Sequential methods spend simulations…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why ABC works. Accepting θ when s(x) lies within ε of s_obs samples from p(θ | ‖s(x) − s_obs‖ ≤ ε). As ε shrinks this tends to p(θ | s_obs), which equals the full posterior p(θ | x_obs) when s is sufficient. For the Poisson model the log-likelihood is Σy·log A − k·Σ t y − A·Σ e^(−kt) plus terms without θ, so (Σy, Σ t y) are sufficient: Exercise 1 confirms that two different count series sharing these sums have the same posterior.
The cost of tolerance. A larger ε accepts parameters whose simulations only roughly match, inflating the posterior. In Exercise 2 accepting 10% of simulations gave posterior standard deviation 0.05 for k against the exact 0.038; accepting 1% gave 0.039.
Regression and amortisation. Beaumont’s adjustment removes the linear trend of θ in s − s_obs inside the accepted set, recovering the exact standard deviation from the 10% set. The amortised Gaussian estimator fits the posterior mean and log variance as functions of the summaries once, then answers any new dataset instantly; this is the idea of NPE with a very simple density family.
- 1. Rejection ABC with 10% acceptance gave a posterior sd of k of…
- 2. Sufficient summaries mean…
- 3. The regression adjustment removes…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How close do rejection ABC, regression-adjusted ABC and an amortised posterior estimator come to the exact posterior, and are their intervals calibrated?
History.
- D. Rubin (1984) described the rejection idea; J. Pritchard et al. (1999) applied ABC in population genetics.
- M. Beaumont, W. Zhang and D. Balding (2002) introduced regression adjustment.
- G. Papamakarios and I. Murray (2016) proposed neural posterior estimation; K. Cranmer, J. Brehmer and G. Louppe (2020) reviewed the field.
- S. Talts et al. (2018) proposed simulation-based calibration.
Exercise 2. 50 000 simulations from the prior; observed data from A = 20, k = 0.2. Posterior of k (mean ± standard deviation), seed 0:
| method | posterior of k |
|---|---|
| exact (grid) | 0.24 ± 0.038 |
| rejection ABC, 10% accepted | 0.25 ± 0.05 |
| rejection ABC, 1% | 0.24 ± 0.039 |
| rejection ABC, 0.1% | 0.25 ± 0.035 |
| rejection ABC, 1%, total count only | 0.33 ± 0.12 |
| regression-adjusted ABC, 10% | 0.24 ± 0.038 |
| amortised Gaussian estimator | 0.24 ± 0.041 |
- Tolerance: 10% acceptance inflated the spread by about a third; 1% and 0.1% matched the exact posterior within sampling noise.
- Summaries: with the total count alone, k is poorly identified and the posterior is three times wider.
- Calibration: over 100 fresh datasets, the central 90% intervals for k contained the truth 0.92 (ABC 1%), 0.91 (regression) and 0.92 (amortised) of the time.
- Seeds 1 and 2: exact 0.26 ± 0.043 and 0.21 ± 0.041; amortised 0.27 ± 0.046 and 0.22 ± 0.042; coverage between 0.89 and 0.94 for every method.
Simulation-based inference in practice
- Cosmology: parameters of the universe from galaxy surveys and weak lensing maps.
- Particle physics: inference with detector simulators.
- Epidemiology: transmission parameters from case counts with agent-based models.
- Neuroscience: parameters of biophysical neuron models from recordings.
References
- J. K. Pritchard, M. T. Seielstad, A. Perez-Lezaun and M. W. Feldman (1999). “Population growth of human Y chromosomes: a study of Y chromosome microsatellites.” Molecular Biology and Evolution.
- M. A. Beaumont, W. Zhang and D. J. Balding (2002). “Approximate Bayesian computation in population genetics.” Genetics.
- G. Papamakarios and I. Murray (2016). “Fast ε-free inference of simulation models with Bayesian conditional density estimation.” NeurIPS.
- K. Cranmer, J. Brehmer and G. Louppe (2020). “The frontier of simulation-based inference.” PNAS.
- S. Talts, M. Betancourt, D. Simpson, A. Vehtari and A. Gelman (2018). “Validating Bayesian inference algorithms with simulation-based calibration.” arXiv:1804.06788.