Fugue
A production-ready, monadic probabilistic programming library for Rust. Write elegant probabilistic programs by composing Model values in direct style; execute them with pluggable interpreters and state-of-the-art inference algorithms.
Supported Rust: 1.70+ ⢠Platforms: Linux / macOS / Windows ⢠Crate:
fugue-pplon crates.io
Features
- Monadic PPL: Compose probabilistic programs using pure functional abstractions
- Type-Safe Distributions: 10+ built-in probability distributions with natural return types
- Multiple Inference Methods: MCMC, SMC, Variational Inference, ABC
- Comprehensive Diagnostics: R-hat convergence, effective sample size, validation
- Production Ready: Numerically stable algorithms with memory optimization
- Ergonomic Macros: Do-notation (
prob!), vectorization (plate!), addressing (addr!)
Why Fugue?
- š Type-safe distributions: natural return types (Bernoulli ā
bool, Poisson/Binomial āu64, Categorical āusize) - š§© Direct-style, monadic design: compose
Model<T>values withbind/mapfor explicit, readable control flow - š Pluggable interpreters: prior sampling, replay, scoring, and safe variants for production robustness
- š Production diagnostics: R-hat, ESS, validation utilities, and robust error handling
- ā” Performance-minded: memory pooling, copy-on-write traces, and numerically stable computations
Installation
[]
= "0.1.0"
Quickstart
Example
use *;
use StdRng;
use SeedableRng;
// Run inference with model defined in closure
let mut rng = seed_from_u64;
let samples = adaptive_mcmc_chain;
let mu_values: = samples.iter
.filter_map
.collect;
Documentation
- User Guide - Comprehensive tutorials and examples
- API Reference - Complete API documentation
- Examples - See
examples/directory
Community
- Issues & Bugs: Use GitHub Issues
- Feature Requests: Open an issue with the
enhancementlabel
Roadmap
This project is an ongoing exploration of probabilistic programming in Rust. While many pieces are production-leaning, parts may not be 100% complete or correct yet. Iām steadily working toward a more robust implementation and broader feature set.
Planned focus areas:
- Strengthening core correctness and numerical stability
- Expanding distribution and inference coverage
- API refinements and stability guarantees
- Improved documentation, diagnostics, and examples
Contributing
Contributions welcome! See our contributing guidelines.
&&
License
Licensed under the MIT License.
Built with Rust ⢠Monadic PPL ⢠Type-safe distributions