File size: 1,028 Bytes
c383c28 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/usr/bin/env python3
"""Writes simulation_parameters_table.tex from capacity_parameters.json."""
import json
from pathlib import Path
P = json.loads(Path("capacity_parameters.json").read_text())
f = lambda r, k: f"{r[k]:.2f} [{r[k+'_ci'][0]:.2f}, {r[k+'_ci'][1]:.2f}]"
rows = [("Logistic control", "4.35 (true)", P["direct_control"]),
("Additive", "4.35", P["additive"]),
("Correlated", "4.35 (naive)", P["correlated"]),
("Batched", "4.35 (naive)", P["batched"]),
("Switching", "4.35 (naive)", P["switching"])]
out = [r"\begin{tabular}{lccccc}", r"\toprule",
r"Condition & nominal $n_0$ & fitted $n_{\mathrm{mid}}$ & width $\tau$ & floor $\mathrm{SC}_{\min}$ & ceiling $\mathrm{SC}_{\max}$ \\",
r"\midrule"]
for name, n0, r in rows:
out.append(f"{name} & {n0} & {f(r,'midpoint')} & {f(r,'tau')} & {f(r,'floor')} & {f(r,'ceiling')} \\\\")
out += [r"\bottomrule", r"\end{tabular}"]
Path("simulation_parameters_table.tex").write_text("\n".join(out) + "\n")
print("\n".join(out))
|