How to choose an inference method

How to choose an inference method#

sbi implements three main neural inference families:

  • NPE (Neural Posterior Estimation),

  • NLE (Neural Likelihood Estimation), and

  • NRE (Neural Ratio Estimation).

Each family learns a different probability distribution from simulations, which affects how posterior samples are obtained and which data types are easiest to handle. The neural estimators are usually amortized: they are trained across observations and can be reused for new observations. They can also be used in sequential workflows tailored to one observation.

sbi also implements vector-field methods, FMPE and NPSE, which estimate the posterior with flow matching or score matching instead of a normalizing flow. Their sampling and training trade-offs differ; see how to use FMPE and NPSE.

Recommendations#

  • For high-dimensional simulation outputs such as images or time series, start with NPE or NRE and use an embedding network.

  • If low sampling latency is important, NPE directly produces posterior samples after training.

  • For IID observations, meaning several independent trials \(x_1, \dots, x_N\) generated from the same parameter \(\theta\), NLE or NRE can be especially useful; see the IID-data guide.

  • Use amortized neural-estimator training when the same learned estimator should support many observations. Consider a sequential (multiround) method when tailoring simulations to one observation is worth the additional rounds.

NPE vs NLE vs NRE#

NPE directly estimates the posterior, \(q(\theta \mid x) \approx p(\theta \mid x)\). It does not require an additional sampler after training, so repeated .sample() calls are fast. NPE can use an embedding network, trained jointly with the density estimator, to learn features of structured or high-dimensional observations.

NLE learns the conditional distribution of observations given parameters, \(q(x \mid \theta) \approx p(x \mid \theta)\). After training, it can act as a fast emulator: for a chosen parameter value, synthetic observations can be generated without running the original simulator. Learning the full distribution of high-dimensional observations can be challenging, so data reduction or NPE/NRE may be more practical in that setting. To obtain posterior samples, combine the learned likelihood with the prior via \(p(\theta \mid x_o) \propto p(x_o \mid \theta)\,p(\theta)\) and pick a method from the sampler guide. NLE can be simulation-efficient for IID observations.

NRE learns the likelihood-to-evidence ratio, \(r(\theta, x) \approx p(x \mid \theta) / p(x)\), with a classifier, so that \(p(\theta \mid x_o) \propto r(\theta, x_o)\,p(\theta)\). Like NLE, it needs an additional posterior sampler. Like NPE, it can use an embedding network, trained jointly with the classifier, for structured observations.

Each family has several variants. NPE resolves to NPE_C and NRE resolves to NRE_B; NPE_A, NPE_B, NRE_A, NRE_C, and BNRE are available under their own names.

Amortized or sequential neural inference#

An amortized neural estimator is trained across simulated observations and can be reused for new observations without new simulations or estimator retraining. A sequential workflow concentrates later simulation rounds around a particular observation and can improve simulation efficiency for that observation. Choose based on how often the estimator will be reused, simulation cost, and the benefit of observation-specific simulations rather than a fixed observation-count threshold.