"""Job #4611 (step check, route 25): custody of the served T_31/T_37 gap histograms (return #2005's tc31.json / tc37.json) against the step's own asserts -- D = prod_{3<=p<=x}(p-2), sum of gaps = x#, max gap = Ghat -- plus lambda_real = m* * gbar / Ghat from #1850's m*. Reads served files only; no tile pass.""" import json, hashlib from math import prod PR = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37] for x, fn, G, mstar in ((31, 'tc31.json', 348, 26), (37, 'tc37.json', 528, 41)): b = open(fn, 'rb').read(); tc = json.loads(b); c = {int(k): v for k, v in tc['census'].items()} P = prod(p for p in PR if p <= x); D = prod(p - 2 for p in PR if 3 <= p <= x) gbar = P / D print(f"x={x} {fn} sha256 {hashlib.sha256(b).hexdigest()[:16]}: bins {len(c)}, sum N_g = D {sum(c.values()) == D == tc['D']} ({D}), " f"sum g*N_g = x# {sum(g * n for g, n in c.items()) == P}, max gap = Ghat {max(c) == G == tc['G2']}; " f"gbar/Ghat = {gbar / G:.5f}, lambda_real = m* gbar/Ghat = {mstar * gbar / G:.4f}")