π KrakΓ³w, Poland | 90 minutes | Intermediate Track
By the end of this tutorial, you will:
- Understand when and why to use Simulation-Based Inference (SBI)
- Run parameter inference for any Python simulator using the
sbipackage - Diagnose whether your inference results are trustworthy
- Apply SBI to your own scientific problems
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone this repository
git clone https://github.com/janfb/euroscipy-2025-sbi-tutorial.git
cd euroscipy-2025-sbi-tutorial
# Create environment and install dependencies
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv sync
```text
### 2. Test Your Setup
```python
# Run this to verify installation
python -c "import sbi; import torch; print('β
Setup complete!')"- You can run the notebooks in VSCode or a similar IDE, selecting the
euroscipy-2025-sbi-tutorialpython kernel - Alternatively, you can start
jupyter notebookin the terminal and work on the notebooks in the browser.
-
Read a bit about SBI:
-
Bring Your Simulator: If you have a scientific simulator you'd like to apply SBI to, prepare a simplified version that:
- Takes parameters as input (numpy array or torch tensor)
- Returns observations as output (numpy array or torch tensor)
- Runs in < 1 second per simulation
- Example:
def simulator(params): return observations
- The Environmental Monitoring Challenge
- Point estimates vs. uncertainty quantification
- When traditional methods fail
- Rejection sampling in 5 lines of code
- Neural Posterior Estimation concept
- Learning parameter-data relationships
- Lotka-Volterra predator-prey model
- Running NPE with
sbi - Visualizing posterior distributions
- Posterior predictive checks
- Coverage diagnostics
- Interpreting warning signs
- Adapt template to your simulator
- OR use provided examples (ball throw, SIR model)
- Specify priors and run inference
- Advanced SBI methods (NLE, NRE, sequential)
- Resources and community
euroscipy-2025-sbi-tutorial/
βββ README.md # This file
βββ pyproject.toml # Project dependencies
βββ materials/
βββ 2024-08-30-EuroSciPy2024-SBI.pdf # Optional pre-reading
βββ references.md # Further resources
βββ slides/ # Presentation slides
β βββ sbi_tutorial.md
βββ sbi_tutorial.pdf
βββ src/
β βββ 00_setup_test.py # Verify installation
β βββ 01_first_inference.ipynb # Exercise 1
β βββ 02_diagnostics.ipynb # Exercise 2
β βββ 03_your_sbi_problem.ipynb # Exercise 3
β βββ simulators/ # Example simulators
β βββ lotka_volterra.py
β βββ ball_throw.py
β βββ sir_model.py
βββ utils.py # Plotting utils
- Python 3.10+
- Basic familiarity with PyTorch tensors
- Understanding of your own simulator (if bringing one)
- Jan Teusen (Boelts), TransferLab, appliedAI Institute for Europe
- Janos Gabler, TransferLab, appliedAI Institute for Europe
- Kristof SchrΓΆder, TransferLab, appliedAI Institute for Europe
- Before the tutorial: Open an issue on GitHub
- During the tutorial: Raise your hand
- After the tutorial: Join the sbi community on GitHub Discussions
- SBI community: https://github.com/sbi-dev/sbi/graphs/contributors
- Funding: TransferLab, appliedAI Institute for Europe
- Organization: EuroSciPy 2025
This tutorial is licensed under Apache 2.0.