# Score E19 with grader v2: majority vote over normalized boxed answers (ties go to the lowest seed), # and a paired exact McNemar test against the greedy E17 run (e17_math500_greedy.jsonl). import json, math from collections import Counter import math_grade_v2 as G2 E17 = {} for l in open("e17_math500_greedy.jsonl", encoding="utf-8"): r = json.loads(l); E17[r["item"]] = bool(G2.correct(r["text"], r["gold"])) maj = orc = b = c = tok = 0 for l in open("e19_math500_sc4.jsonl", encoding="utf-8"): r = json.loads(l); S = r["samples"] for s in S: s["n"] = G2.norm(s["boxed"]) if s["boxed"] else None s["ok"] = bool(G2.correct(s["text"], r["gold"])) tok += sum(s["predicted_n"] or 0 for s in S) cnt = Counter(s["n"] for s in S if s["n"] is not None) ok = False if cnt: top = max(cnt.values()); win = next(s["n"] for s in S if s["n"] is not None and cnt[s["n"]] == top) ok = next(s["ok"] for s in S if s["n"] == win) maj += ok; orc += any(s["ok"] for s in S) g = E17[r["item"]]; b += g and not ok; c += ok and not g n = b + c; p = min(1, 2 * sum(math.comb(n, i) for i in range(min(b, c) + 1)) / 2 ** n) if n else 1 print(f"greedy {sum(E17.values())}/500 sc@4 {maj}/500 oracle {orc}/500 greedy-only {b} sc-only {c} McNemar p={p:.3g} tokens {tok}")