Examples#
This page provides links and descriptions for example notebooks and scripts demonstrating the use of GenSBI. Every notebook is a self-contained example that can be run independently.
All examples are available in the GenSBI-examples repository.
Tip
New to GenSBI? Start with the Quick Start Guide and the my_first_model notebook for a complete walkthrough.
Getting Started#
My First Model Tutorial#
Recommended starting point for beginners. This comprehensive tutorial walks through:
Setting up a simple simulation-based inference problem
Training a flow matching model
Sampling from the posterior
Validating results with SBC, TARP, and L-C2ST
Unconditional Density Estimation#
These examples demonstrate how to use flow matching and diffusion models for unconditional density estimation in 2D. These are useful for understanding the basics of generative modeling before moving to conditional inference.
What you’ll learn:
How to train flow matching models on arbitrary 2D distributions
How to train diffusion models on 2D data
Basics of data preparation and visualization
Posterior Density Estimation: SBI Benchmarks#
This series of examples demonstrates how to use GenSBI for posterior density estimation on standard Simulation-Based Inference benchmarks. These benchmarks are commonly used to evaluate SBI methods.
Two Moons Problem#
The two moons problem is a classic 2D benchmark with a bimodal posterior. Great for visualizing how flow matching captures multimodal distributions.
What you’ll learn:
How to use the Simformer model on simple problems
How to use the Flux1 model on simple problems
Visualizing bimodal posterior distributions
Gaussian Linear Problem#
The Gaussian linear problem involves inferring parameters of a linear Gaussian model. This is a higher-dimensional problem that tests scalability.
What you’ll learn:
Using Simformer for medium-dimensional problems
Using Flux1Joint for explicit joint modeling
Handling higher-dimensional inference
SLCP (Simple Likelihood Complex Posterior)#
The SLCP benchmark features a simple likelihood but a complex, multimodal posterior distribution. This tests how well models can learn intricate posterior structures.
What you’ll learn:
Handling complex multimodal posteriors
Using Simformer for challenging distributions
Running the Examples#
Option 1: Google Colab (Easiest)#
Most examples include a “Open in Colab” badge. Click it to run the notebook in Google Colab without any local setup.
Option 2: Local Jupyter#
Clone the examples repository:
git clone https://github.com/aurelio-amerio/GenSBI-examples.git cd GenSBI-examples
Install dependencies (see the Installation Guide for details):
pip install jupyter pip install "GenSBI[cuda12] @ git+https://github.com/aurelio-amerio/GenSBI.git"
Launch Jupyter:
jupyter notebookOpen and run the notebooks in the
examples/directory.
Next Steps#
After exploring the examples:
Understand the Architecture: Read the Conceptual Overview to understand how GenSBI is structured.
Choose Your Model: See Model Cards for guidance on selecting the right model for your problem.
Dive Deeper: Read the Training Guide, Inference Guide, and Validation Guide.
Apply to Your Problem: Use GenSBI for your own simulation-based inference tasks!
Questions or Issues?#
Check the Troubleshooting Guide for common issues
Open an issue on the GitHub repository
Read the API Documentation for detailed function signatures