Skip to main content

Simulation-based inference.

Project description

PyPI version Conda Version Contributions welcome Tests codecov GitHub license DOI NumFOCUS affiliated

sbi: Simulation-Based Inference

Getting Started | Documentation | Discord Server

sbi is a Python package for simulation-based inference, designed to meet the needs of both researchers and practitioners. Whether you need fine-grained control or an easy-to-use interface, sbi has you covered.

With sbi, you can perform parameter inference using Bayesian inference: Given a simulator that models a real-world process, SBI estimates the full posterior distribution over the simulator’s parameters based on observed data. This distribution indicates the most likely parameter values while additionally quantifying uncertainty and revealing potential interactions between parameters.

Key Features of sbi

sbi offers a blend of flexibility and ease of use:

  • Low-Level Interfaces: For those who require maximum control over the inference process, sbi provides low-level interfaces that allow you to fine-tune many aspects of your workflow.
  • High-Level Interfaces: If you prefer simplicity and efficiency, sbi also offers high-level interfaces that enable quick and easy implementation of complex inference tasks.

In addition, sbi supports a wide range of state-of-the-art inference algorithms (see below for a list of implemented methods):

  • Amortized Methods: These methods enable the reuse of posterior estimators across multiple observations without the need to retrain.
  • Sequential Methods: These methods focus on individual observations, optimizing the number of simulations required.

Beyond inference, sbi also provides:

  • Validation Tools: Built-in methods to validate and verify the accuracy of your inferred posteriors.
  • Plotting and Analysis Tools: Comprehensive functions for visualizing and analyzing results, helping you interpret the posterior distributions with ease.

Getting started with sbi is straightforward, requiring only a few lines of code:

from sbi.inference import NPE
# Given: parameters theta and corresponding simulations x
inference = NPE(prior=prior)
inference.append_simulations(theta, x).train()
posterior = inference.build_posterior()

Installation

sbi requires Python 3.10 or higher. While a GPU isn't necessary, it can improve performance in some cases. We recommend using uv for package management:

uv pip install sbi

Pyro and PyMC MCMC samplers are optional. Install them as needed:

uv pip install "sbi[pyro]"   # for Pyro samplers (HMC, NUTS)
uv pip install "sbi[pymc]"   # for PyMC samplers (HMC, NUTS, Slice)
uv pip install "sbi[all]"    # both Pyro and PyMC

For conda, pixi, pip, and other installation methods, see the full installation guide.

Testing the installation

Open a Python prompt and run

from sbi.examples.minimal import simple
posterior = simple()
print(posterior)

Tutorials

If you're new to sbi, we recommend starting with our Getting Started tutorial.

You can also access and run these tutorials directly in your browser by opening Codespace. To do so, click the green “Code” button on the GitHub repository and select “Open with Codespaces.” This provides a fully functional environment where you can explore sbi through Jupyter notebooks.

You might also find this tutorial paper useful: Deistler, M., Boelts, J., Steinbach, P., Moss, G., Moreau, T., Gloeckler, M., ... & Macke, J. H. (2025). Simulation-based inference: A practical guide. arXiv preprint arXiv:2508.12939.. It describes the SBI workflow and offers practical guidelines and diagnostic tools for every stage of the process: from setting up the simulator and prior, choosing and training inference networks, to performing inference and validating the results. It also includes several worked examples.

Inference Algorithms

The following inference algorithms are currently available. You can find instructions on how to run each of these methods here.

Neural Posterior Estimation: amortized (NPE) and sequential (SNPE)

Neural Likelihood Estimation: amortized (NLE) and sequential (SNLE)

Neural Ratio Estimation: amortized (NRE) and sequential (SNRE)

Neural Variational Inference, amortized (NVI) and sequential (SNVI)

Mixed Neural Likelihood Estimation (MNLE)

Feedback and Contributions

We welcome any feedback on how sbi is working for your inference problems (see Discussions) and are happy to receive bug reports, pull requests, and other feedback (see contribute). We wish to maintain a positive and respectful community; please read our Code of Conduct. To report a security vulnerability, please see our Security Policy.

Acknowledgments

sbi is the successor (using PyTorch) of the delfi package. It started as a fork of Conor M. Durkan's lfi. sbi runs as a community project. See also credits.

Support

sbi has been supported by the German Federal Ministry of Education and Research (BMBF) through project ADIMEM (FKZ 01IS18052 A-D), project SiMaLeSAM (FKZ 01IS21055A) and the Tübingen AI Center (FKZ 01IS18039A). Since 2024, sbi is supported by the appliedAI Institute for Europe, and by NumFOCUS.

License

Apache License Version 2.0 (Apache-2.0)

Citation

The sbi package has grown and improved significantly since its initial release, with contributions from a large and diverse community. To reflect these developments and the expanded functionality, we published an updated JOSS paper. We encourage you to cite this newer version as the primary reference:

@article{BoeltsDeistler_sbi_2025,
  doi = {10.21105/joss.07754},
  url = {https://doi.org/10.21105/joss.07754},
  year = {2025},
  publisher = {The Open Journal},
  volume = {10},
  number = {108},
  pages = {7754},
  author = {Jan Boelts and Michael Deistler and Manuel Gloeckler and Álvaro Tejero-Cantero and Jan-Matthis Lueckmann and Guy Moss and Peter Steinbach and Thomas Moreau and Fabio Muratore and Julia Linhart and Conor Durkan and Julius Vetter and Benjamin Kurt Miller and Maternus Herold and Abolfazl Ziaeemehr and Matthijs Pals and Theo Gruner and Sebastian Bischoff and Nastya Krouglova and Richard Gao and Janne K. Lappalainen and Bálint Mucsányi and Felix Pei and Auguste Schulz and Zinovia Stefanidi and Pedro Rodrigues and Cornelius Schröder and Faried Abu Zaid and Jonas Beck and Jaivardhan Kapoor and David S. Greenberg and Pedro J. Gonçalves and Jakob H. Macke},
  title = {sbi reloaded: a toolkit for simulation-based inference workflows},
  journal = {Journal of Open Source Software}
}

This updated paper, with its expanded author list, reflects the broader community contributions and the package's enhanced capabilities in releases 0.23.0 and later.

If you are using a version of sbi prior to 0.23.0, please cite the original sbi software paper:

@article{tejero-cantero2020sbi,
  doi = {10.21105/joss.02505},
  url = {https://doi.org/10.21105/joss.02505},
  year = {2020},
  publisher = {The Open Journal},
  volume = {5},
  number = {52},
  pages = {2505},
  author = {Alvaro Tejero-Cantero and Jan Boelts and Michael Deistler and Jan-Matthis Lueckmann and Conor Durkan and Pedro J. Gonçalves and David S. Greenberg and Jakob H. Macke},
  title = {sbi: A toolkit for simulation-based inference},
  journal = {Journal of Open Source Software}
}

Regardless of which software paper you cite, please also remember to cite the original research articles describing the specific sbi-algorithm(s) you are using.

Specific releases of sbi are also citable via Zenodo, where we generate a new software DOI for each release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbi-0.26.1.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sbi-0.26.1-py3-none-any.whl (517.9 kB view details)

Uploaded Python 3

File details

Details for the file sbi-0.26.1.tar.gz.

File metadata

  • Download URL: sbi-0.26.1.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sbi-0.26.1.tar.gz
Algorithm Hash digest
SHA256 bcdcd9f19318815e8e6314523f23b727b509f02c8e657cf3696c30231d23fc07
MD5 f20172c2b342914960ec2a776f63e4ba
BLAKE2b-256 38505ab2aa359d0089a97ab855a47c6349166d1bb9a654f7a3496e57be895063

See more details on using hashes here.

Provenance

The following attestation bundles were made for sbi-0.26.1.tar.gz:

Publisher: publish.yml on sbi-dev/sbi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sbi-0.26.1-py3-none-any.whl.

File metadata

  • Download URL: sbi-0.26.1-py3-none-any.whl
  • Upload date:
  • Size: 517.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sbi-0.26.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3d18b78f79bb2005154f02bb5ec7cd281873e6e2def72e989dd486019d85dd40
MD5 788781ba0d9e5ed25ae1c7d72c3dc379
BLAKE2b-256 979cdfec7c59a04e1656c3e71daa0fce2dfc74362fe8819a60ff6e66c3b9c21d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sbi-0.26.1-py3-none-any.whl:

Publisher: publish.yml on sbi-dev/sbi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page