Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

ƒ

Fugue

A type-safe, monadic probabilistic programming library for Rust — compose models in direct style, listen backwards with state-of-the-art inference.

Crates.io Dev Docs CI codecov License: MIT Discord

Fugue Evo Evolution as Bayesian inference — CMA-ES, NSGA-II, island models, and estimation-of-distribution algorithms on the same foundations, with its own live playground.

About Fugue

  • 🧩 Monadic PPL: Compose probabilistic programs as pure Model values, 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 (Bernoullibool, Poissonu64, Categoricalusize) — 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!)

🧪 Where Fugue stands today

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"

More Resources