Files
sim-numerics/table_wins_losses.py
vvsandClaude Opus 5 bbb16ec81c PREREG_half_contra outcome: ACCEPTED (server = smoke in every projection cell; 0 violations in the guaranteed family).
'half': the step promises the root in the half near x (S >= 1/2) while the bracket line puts it in the far half (smaller |f| at the far end) -> halve.
  half alone                                  APS 2806 -> 2564 (!)  CHA 3220 -> 3202
  G2 + contra + rem + point + exp + half      APS 2773 -> 2559  CHA 2073 -> 2047  both 4606 (all of H1-H4; goal kept)
     per problem vs Chandrupatla: APS 98/17/38 p=2.7e-7, CHA 27/6/7 p=8e-4
  contra + rem + point + exp + half (no G2)   APS 2551  CHA 2044  both 4595 (H2 fails by 24)
  with defect it does not combine (APS 2531 -> 2651): the two refuse overlapping steps.
fun9: 77 -> 68 (Chandrupatla 55); fun9.5 24 -> 16.
Server regression x2: 1204 passed, 1 failed = the paper-number check.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-21 19:24:31 +01:00

69 lines
3.2 KiB
Python

"""Comparative table of our wins and losses (server results only).
Variants of the proposed rule (tent, 3-point, projection) against the library Chandrupatla,
Brent (brentq) and TOMS748: totals per set, both sets, and per-problem wins/ties/losses with
the sign test; then the wide-bracket set per family.
python -u table_wins_losses.py
"""
from __future__ import annotations
import json
from analyze_extrap import h2h, sign_p
from where_we_lose import per_family
def load(p):
with open(p, encoding="utf8") as fh:
return {r["label"]: r for r in json.load(fh)}
def main():
full = load("sweep_full.json")
dc = load("sweep_defcontra.json")
op = load("sweep_orderpt.json")
ex = load("sweep_explimit.json")
hf = load("sweep_half.json")
rivals = {"Chandrupatla": full["chandrupatla"], "Brent": full["brent"],
"TOMS748": full["toms748"]}
ours = {
"proposed rule": full["pure.ratio.derived3.project"],
"+ G2 (step pattern)": dc["pure+extP.ratio.derived3.project"],
"+ G2 + analogy entry": dc["pure+extP+flatanalog.ratio.derived3.project"],
"+ contra + remembered analogy": dc["contra+flatanalogmem.ratio.derived3.project"],
"+ defect + remembered analogy": dc["defect+flatanalogmem.ratio.derived3.project"],
"+ G2 + analogy + ORDER POINT": op["pure+extP+flatanalogpt.ratio.derived3.project"],
"+ G2 + contra + rem. + ORDER PT": op["pure+extP+contra+flatanalogmempt.ratio.derived3.project"],
"+ defect + rem. + ORDER POINT": op["defect+flatanalogmempt.ratio.derived3.project"],
"+ G2 + contra + rem. + pt + EXP": ex["pure+extP+contra+flatanalogmempt+exp.ratio.derived3.project"],
"+ defect + rem. + pt + EXP": ex["defect+flatanalogmempt+exp.ratio.derived3.project"],
"+ half (alone)": hf["half.ratio.derived3.project"],
"+ G2 + contra + rem + pt + exp + HALF": hf["pure+extP+contra+flatanalogmempt+exp+half.ratio.derived3.project"],
"+ contra + rem + pt + exp + HALF": hf["contra+flatanalogmempt+exp+half.ratio.derived3.project"],
}
print("TOTALS (evaluations of f, failures charged 200)")
print(f" {'method':<32} {'APS':>6} {'CHA':>6} {'both':>6}")
for name, r in list(ours.items()) + list(rivals.items()):
print(f" {name:<32} {r['APS']['total']:6d} {r['CHA']['total']:6d} "
f"{r['APS']['total'] + r['CHA']['total']:6d}")
print("\nPER PROBLEM, ours against each rival: wins/ties/losses (sign-test p)")
for s in ("APS", "CHA"):
print(f" {s}")
for name, r in ours.items():
cells = []
for rn, rv in rivals.items():
w, t, l = h2h(r, rv, s)
cells.append(f"{rn} {w}/{t}/{l} p={sign_p(w, l):.2g}")
print(f" {name:<32} " + " ".join(cells))
print("\nCHA PER FAMILY (ours / Chandrupatla)")
fams = sorted(per_family(rivals["Chandrupatla"], "CHA"))
print(" " + " " * 32 + "".join(f"{f:>9}" for f in fams))
for name, r in list(ours.items()) + [("Chandrupatla", rivals["Chandrupatla"])]:
pf = per_family(r, "CHA")
print(f" {name:<32}" + "".join(f"{pf[f]:9d}" for f in fams))
if __name__ == "__main__":
main()