Inference Methods & Examples¶
VBI provides multiple approaches for parameter inference, each with different strengths and use cases.
Inference Method Overview¶
Method |
Dependencies |
Performance |
Best For |
|---|---|---|---|
CDE (Conditional Density Estimation) |
NumPy + autograd |
Fast, lightweight |
Quick inference, limited resources |
SBI (Simulation-Based Inference) |
PyTorch + sbi |
State-of-the-art |
Complex problems, research |
CDE-Based Inference (Lightweight)¶
Conditional Density Estimation using pure NumPy implementation - no PyTorch required.
Key Features:
✅ Lightweight: Only requires NumPy and autograd
✅ Fast: Efficient implementation for moderate-scale problems
✅ Transparent: Clear mathematical foundation
✅ Flexible: Easy to customize and extend
Documentation & Tutorials¶
Quick Start:
CDE Quick Start: Mixture Density Networks (MDN) - Quick Start Guide for MDN (5-minute read)
Complete Reference:
CDE API Guide: Conditional Density Estimation - Comprehensive API Documentation for MDN and MAF (includes theory, usage, and best practices)
Example Notebooks¶
Complete examples demonstrating CDE inference on various brain models:
When to use CDE:
Limited computational resources
Want to avoid heavy PyTorch dependency
Need transparent, interpretable inference
SBI-Based Inference (Advanced)¶
Simulation-Based Inference using PyTorch and the sbi library - state-of-the-art methods.
Key Features:
🚀 State-of-the-art: Latest neural density estimation techniques
🧠 Scalable: Handles high-dimensional problems efficiently
🔧 Comprehensive: Multiple inference algorithms (SNPE, SNLE, SNRE)
Current Examples:
Note: Most simulation examples currently use SBI for inference. We’re working on separating these into dedicated inference tutorials.
When to use SBI:
Working with high-dimensional parameter spaces (> 10 parameters)
Need state-of-the-art performance
Complex, multimodal posterior distributions
Getting Started¶
For CDE Inference:
Start with CDE Quick Start: Mixture Density Networks (MDN) - Quick start with MDN
Read CDE API Guide: Conditional Density Estimation - Comprehensive API guide for MDN and MAF
Try example notebooks:
Damped Oscillator - CDE - Simple damped oscillator
Jansen-Rit whole brain (NUMBA) - Jansen-Rit neural mass model
Wilson-Cowan SDE model in Numba - Wilson-Cowan model
Apply to your brain model of choice
For SBI Inference:
Install full VBI:
pip install vbi[inference]Check existing simulation examples that include SBI
Adapt to your specific use case
Upcoming Examples¶
We’re working on expanding the inference examples:
CDE + Brain Models: Direct application to Jansen-Rit, Wilson-Cowan models
SBI Tutorials: Dedicated SBI workflow examples
Method Comparisons: Side-by-side CDE vs SBI comparisons
Real Data Examples: Using experimental neuroimaging data
Performance Guidelines¶
CDE Performance Tips:
Use appropriate number of mixture components (MDN) or layers (MAF)
Monitor training convergence carefully
Consider data preprocessing/normalization
SBI Performance Tips:
Use GPU acceleration when available
Tune simulation budget vs accuracy trade-off
Consider sequential vs single-round inference
Memory and Speed:
CDE: Lower memory usage, faster setup
SBI: Higher memory usage, potentially faster inference for complex problems
Contributing¶
We welcome contributions of new inference examples! See our CONTRIBUTING.md for guidelines on adding new tutorials and examples.