Swyft v0.4¶
swyft is the official implementation of Truncated Marginal Neural Ratio Estimation (TMNRE), a hyper-efficient, simulation-based inference technique for complex data and expensive simulators. As of v0.4.0, swyft is based on pytorch-lightning.
Swyft in action¶

Swyft makes it convenient to perform Bayesian or Frequentist inference of hundreds, thousands or millions of parameter posteriors by constructing optimal data summaries.
To this end, Swyft estimates likelihood-to-evidence ratios for arbitrary marginal posteriors; they typically require fewer simulations than the corresponding joint.
Swyft performs targeted inference by prior truncation, combining simulation efficiency with empirical testability.
Swyft is based on stochastic simulators, which map parameters stochastically to observational data. Swyft makes it convenient to define such simulators as graphical models.
In scientific settings, a cost-benefit analysis often favors approximating the posterior marginality; swyft provides this functionality.
The package additionally implements our prior truncation technique, routines to empirically test results by estimating the expected coverage, and a simulator manager with zarr storage to simplify use with complex simulators.
Further information¶
Documentation & installation: https://swyft.readthedocs.io/
Example usage: https://swyft.readthedocs.io/en/latest/tutorial-notebooks.html
Source code: https://github.com/undark-lab/swyft
Support & discussion: https://github.com/undark-lab/swyft/discussions
Bug reports: https://github.com/undark-lab/swyft/issues
Contributing: https://swyft.readthedocs.io/en/latest/contributing-link.html
Citation: https://swyft.readthedocs.io/en/latest/citation.html
Swyft history¶
tmnre is the implementation of the paper Truncated Marginal Neural Ratio Estimation.
v0.1.2 is the implementation of the paper Simulation-efficient marginal posterior estimation with swyft: stop wasting your precious time.
sbi is a collection of simulation-based inference methods. Unlike swyft, the repository does not include truncation nor marginal estimation of posteriors.
Basics:
Reference: