Outputs and plots
Chain files
With output="chains/run", every sampler writes Cobaya-format files that getdist and
anesthetic read as they are:
| File | Content |
|---|---|
run.1.txt, ... |
One chain per file: weight, \(-\log\) posterior, parameters, derived (*) |
run.covmat |
Covariance of the sampled parameters |
run.updated.yaml |
Settings, labels and the results diagnostics |
run.adaptation.npz |
Step size and mass matrix, for resuming NUTS and HMC |
run_dead-birth.txt, run.nested_state.npz |
Nested sampling's points and resume state |
run.bestfit.yaml, run.profile.* |
From maximize and profile |
save_chains writes the same format from any result.
from getdist import loadMCSamples
samples = loadMCSamples("chains/run")
Diagnostics
NUTS and HMC results carry \(\hat R\), ESS and divergences; result.summary() prints them.
rhat works on any (chains, n, d) array, with the "rank"
(default) or "gelman-rubin" variant.
Figures
All figures use cplots, installed through the
plots dependency group:
uv sync --group plots
uv run --group plots cosmonuts plot triangle chains/run -p H0,Omega_m,w0,wa
uv run --group plots cosmonuts plot trace chains/run
uv run --group plots cosmonuts plot stats chains/run --limits
plot triangle overlays several runs (roots or run files), marks truths with
-t name=value and sizes for a journal with --paper PRD|PRD-2col|MNRAS|A4.
From Python:
import cplots
from cosmonuts.plotting import load_run
run = load_run("chains/run")
cplots.TrianglePlot(run.samples, run.parameter_names, weights=run.weights).save("triangle.pdf")
Note
Do not build figures with matplotlib.pyplot or getdist directly in this project:
cplots wraps both.