Releases: borodark/exmc
Releases · borodark/exmc
I
Four Chains, Zero Locks
Exmc and ExmcViz: a probabilistic programming framework and native MCMC visualization toolkit for the BEAM.
Exmc — Probabilistic Programming for Elixir
Model Specification
- Declarative IR with
BuilderAPI:rv,obs,detnodes - 9 distributions: Normal, HalfNormal, Exponential, Gamma, Beta, Uniform, StudentT, Cauchy, LogNormal
- Hierarchical models via string parameter references (
sigma: "sigma") - Vectorized observations — pass a tensor to
Builder.obs, reduction is automatic - Rewrite pipeline with composable named passes
Sampling
- Full NUTS sampler (Betancourt 2017) with multinomial tree building
- Stan-style three-phase warmup: step-size search, initial adaptation, final mass matrix
- Diagonal mass matrix estimation with windowed adaptation
- Dual averaging step-size tuning
- Automatic constraint transforms with Jacobian correction (log, softplus, logit)
- Automatic non-centered parameterization for hierarchical Normals
- Parallel multi-chain sampling —
sample_chains/3compiles once, dispatches viaTask.async_stream - Live streaming:
sample_stream/4sends samples to any process as they're drawn
Diagnostics & Model Comparison
- Effective sample size (ESS) via initial positive sequence estimator
- Split R-hat convergence diagnostic
- WAIC and LOO-CV model comparison
- Prior and posterior predictive sampling
Backend
- Nx tensors with automatic EXLA JIT detection —
value_and_gradis compiled when EXLA is available, falls back to BinaryBackend transparently - Erlang
:randfor PRNG (1000x faster thanNx.Randomon BinaryBackend)
Test Suite: 123 tests (11 doctests + 112 tests), 25 integration tests
ExmcViz — Native MCMC Diagnostics
ArviZ-style visualization through Scenic's OpenGL pipeline on a true-black OLED palette.
Visualization Types
- Dashboard (
show/3) — trace plot, histogram, ACF, summary panel per variable; energy plot at bottom; dynamic proportional layout - Pair plot (
pair_plot/2) — k x k grid: histogram diagonal, scatter lower triangle, Pearson correlation upper triangle - Forest plot (
forest_plot/2) — horizontal HDI intervals (50% + 94%) with posterior mean dots - Live streaming (
stream/3) — real-time dashboard updated via GenServer coordinator buffering 10 samples per flush
Features
- Multi-chain overlay with 10-color warm spectrum
- Divergence markers (red circles on trace plots)
- Energy diagnostics (overlaid marginal + transition histograms)
- Dynamic viewport-proportional layout — priority: trace 50% > histogram+ACF 30% > summary 20% > energy 8%
- 4K portrait optimized (2160 x 3840)
Test Suite: 34 tests
Architecture
35 architectural decisions documented in DECISIONS.md, from :rand vs Nx.Random (D16) to auto-NCP (D32) to compile-once parallel chains (D35).