Bayesian inference, from one command line.
mcmc drives Bayesian modelling end to end: provision a runtime, fit a
model, and run post-inference diagnostics. Stages compose through one declarative
spec file in and one samples file out, so each step stays small and predictable.
Eight schools, end to end.
The textbook hierarchical model, and a textbook trap. Run it, and the diagnostics flag the funnel the centered parameterization hides: high R-hat, low ESS, hundreds of divergences. Drag to zoom any plot.
using Turing
@model function eight_schools(y, sigma)
J = length(y)
mu ~ Normal(0, 5)
tau ~ truncated(Cauchy(0, 5); lower = 0)
theta ~ filldist(Normal(mu, tau), J)
for j in 1:J
y[j] ~ Normal(theta[j], sigma[j])
end
end
build_model(data) = eight_schools(data.y, data.sigma) y,sigma
28,15
8,10
-3,16
7,11
-1,9
1,11
18,10
12,18 $ mcmc run eight_schools.jl --data data.csv Fitting eight_schools.jl with Turing.jl (NUTS, 4 chains x 1000 draws + 1000 warmup) on Julia 1.12.6... ok: run 20260626-062103-35158c (19.8 s, Julia 1.12.6) saved to .mcmc variable mean std r_hat ess_bulk ess_tail mcse hdi -------- ----- ----- ----- -------- -------- ----- ---------------- mu 4.748 3.219 1.042 114 1250 0.319 [-1.604, 10.218] tau 3.436 3.375 1.359 17 15 0.498 [0.310, 9.348] theta[1] 6.447 5.424 1.186 578 983 0.198 [-3.527, 16.557] theta[2] 5.339 4.501 1.101 350 1279 0.202 [-3.439, 13.942] theta[3] 4.312 5.244 1.047 153 1185 0.383 [-6.738, 12.959] theta[4] 5.192 4.664 1.094 304 1534 0.239 [-3.846, 14.176] theta[5] 3.962 4.562 1.043 110 1208 0.449 [-5.701, 11.438] theta[6] 4.378 4.658 1.082 190 1622 0.325 [-4.396, 13.254] theta[7] 6.530 4.773 1.188 579 675 0.183 [-2.170, 15.820] theta[8] 5.309 5.205 1.089 338 1464 0.180 [-4.724, 15.047] divergences: 503 not converged (R-hat <= 1.01, ESS >= 400, divergences <= 0)
A thin, composable workflow.
mcmc orchestrates probabilistic programming languages without
becoming a framework. One spec in, one samples file out.
Fit anywhere
Run Turing, JuliaBUGS, or Stan models through a managed Julia or CmdStan runtime, with the CLI as a thin TypeScript orchestrator.
Diagnostics built in
Compute R-hat, ESS, MCSE, and HDI over your samples to judge convergence with confidence.
Reproducible runs
A declarative spec file in and a samples file out keep every run inspectable and repeatable.
Start in one line.
Install the CLI from npm, then provision the runtime with mcmc setup.
mcmc binary. Run mcmc setup once to provision Julia via juliaup, or mcmc setup --engine stan for CmdStan. npm i -g mcmcjs Quickstart Documentation.
Focused pages for installation, running inference, diagnostics, the CLI reference, and internals.
FAQ
Quick answers for search engines and humans.
What is MCMC.js?
Command-line tools for Bayesian modelling, MCMC inference, and post-inference diagnostics across PPLs.
Does it run the inference?
The CLI is a thin orchestrator. Inference runs in a Julia or CmdStan subprocess; diagnostics are pure TypeScript.
How do I check convergence?
Run mcmc diagnose to compute R-hat, ESS, MCSE, and HDI over your samples.