ƒ
Fugue
A type-safe, monadic probabilistic programming library for Rust — compose models in direct style, listen backwards with state-of-the-art inference.
Getting StartedInstall Fugue and run your first probabilistic model in minutes.
ExplorablesInteractive essays — drag a prior and watch the posterior re-form, roll HMC across a landscape.
PlaygroundWrite
prob! models in the browser and run real inference, compiled to WASM.
How-To GuidesTask-focused recipes: custom distributions, diagnostics, working with traces.
TutorialsFrom the coin-flip Bayes loop to advanced inference, in depth.
API ReferenceThe complete fugue-ppl API, documented on docs.rs.
About Fugue
- 🧩 Monadic PPL: Compose probabilistic programs as pure
Modelvalues, then interpret them with pluggable handlers — effects are interpreted, never performed by the model itself - 🔒 Type-Safe Distributions: 17 built-in distributions with natural return types (
Bernoulli→bool,Poisson→u64,Categorical→usize) — the type system tracks what each draw is - 📊 Multiple Inference Methods: adaptive Metropolis–Hastings, Hamiltonian Monte Carlo, Sequential Monte Carlo (with an unbiased log-evidence estimate), Variational Inference (support-matched guide families), and importance-weighted ABC-SMC (see Advanced Inference)
- 🔍 Comprehensive Diagnostics: split-R̂ convergence, autocorrelation-based effective sample size, Geweke, and closed-form validation
- 🌀 Stack-Safe Interpreter: a trampolined runtime evaluates models in O(1) stack depth — 100 000-site programs run without overflowing
- ⚡ Numerically Stable: log-space computations throughout for robust probability arithmetic
- ✨ Ergonomic Macros: Do-notation (
prob!), vectorization (plate!), addressing (addr!)
Fugue is 0.2.x: pre-1.0, actively developed, with no SemVer stability guarantee yet and a single primary maintainer. It's extensively tested (unit, integration, and statistical regression tests against closed-form posteriors), but that's a different claim from "production-ready" — pin an exact version and expect breaking API changes between 0.x releases as the design settles.
Installation
[dependencies]
fugue-ppl = "0.2.0"