Streaming Bayesian inference in the browser. A Phoenix LiveView frontend for the Exmc probabilistic programming framework — watch MCMC posteriors form in real time.
With deep respect: this UI borrows the mental model and diagnostics expectations set by PyMC and ArviZ. The goal is to preserve correctness and ergonomics, while making the inference process observable as it unfolds.
PyMC gives excellent post-hoc diagnostics. Exmc Live makes those diagnostics visible during sampling:
- Real-time trace and histogram updates as samples arrive.
- Live diagnostics (ESS, divergences, mean/std) without polling.
- A live posterior state updated online during sampling.
- Clear latency telemetry to understand performance.
./start.sh # http://localhost:4000
./start.sh iex # same, with IEx shell attached- Pick a model (conjugate, two-parameter, or hierarchical)
- Enter observations and set warmup/sample counts
- Hit Sample — the NUTS sampler streams results to the browser via WebSocket
The page updates live: trace plots, histograms, running diagnostics (mean, std, ESS), divergence counts, and latency metrics (warmup time, per-sample throughput). For the conjugate normal model, an analytic posterior comparison table appears after sampling completes.
Browser ←WebSocket→ Phoenix.LiveView ←messages→ Exmc.NUTS.Sampler (Task)
Chart.js hooks {:exmc_sample, i, point_map, step_stat}
(trace + histogram) {:exmc_done, num_samples}
- No polling. The sampler sends
{:exmc_sample, ...}messages directly to the LiveView process. - Each batch of 5 samples triggers a
push_eventto the browser. - Chart.js hooks (
TraceChart,HistogramChart) append points incrementally.
| Model | Free RVs | Description |
|---|---|---|
| Conjugate Normal | 1 (mu) |
mu ~ N(0,10), `x |
| Two-Parameter | 2 (mu, sigma) |
mu ~ N(0,10), sigma ~ Exp(1), x ~ N(mu,sigma). |
| Hierarchical | 5 | Two-group hierarchy: mu_global, sigma_global, mu_a, mu_b, sigma_obs. |
Visit http://localhost:4000/cfd for a CFD-oriented observability dashboard that matches the Exmc Live UX standard:
- Residual traces for U and p
- Halo exchange latency timeline
- Per-partition residual tiles
The demo currently streams synthetic metrics but is structured to accept real CFD metrics via LiveView events.
# Unit tests (simulated messages, no real sampling)
mix test --exclude integration
# Full suite including end-to-end sampling
XLA_FLAGS="--xla_gpu_cuda_data_dir=/usr/lib/nvidia-cuda-toolkit" mix test --include integration24 LiveView tests + 5 model tests + 4 controller tests = 33 total.
XLA_FLAGSrequired for models usinglgamma(Exponential distribution). Thestart.shscript sets this automatically.- Port 4000 (dev), configurable via
PORTenv var in production.
| File | Purpose |
|---|---|
lib/exmc_live_web/live/inference_live.ex |
Main LiveView — state machine, message handling, rendering |
lib/exmc_live/models.ex |
Three preset model builders |
assets/js/hooks/trace_chart.js |
Chart.js hook for trace plots |
assets/js/hooks/histogram_chart.js |
Chart.js hook for histograms |
test/exmc_live_web/live/inference_live_test.exs |
24 LiveView tests |

