"""Job 2777 analysis (stdlib). Reads fv_new.out + the gated 1e7/1e8 rows; prints the pre-registered tests.""" import math g, g1, B1 = 0.5772156649015329, -0.0728158454836767, 0.2614972128476428 rows = {10**7: (1903878, 810715.487156), 10**8: (17426029, 7414336.817337)} for line in open("fv_new.out"): n, v, f, _ = line.split(); rows[int(n)] = (int(v), float(f)) P = lambda N: (1 - g) - g1 * (1 - 1 / (math.log(math.log(N)) + B1)) / math.log(N) print(f"{'N':>6} {'V':>14} {'F/V':>12} {'P(N)':>12} {'F/V-P':>10} {'c_eff':>8} {'(F/V-(1-g))lnN':>15}") for N in sorted(rows): v, f = rows[N]; r = f / v; ll = math.log(math.log(N)) print(f"1e{round(math.log10(N)):<4} {v:>14} {r:>12.9f} {P(N):>12.9f} {r-P(N):>+10.2e} {(0.5-r)*ll:>8.5f} {(r-(1-g))*math.log(N):>15.6f}") step = [10**7, 10**8, 10**9, 10**10] y = [0.5 - rows[N][1] / rows[N][0] for N in step]; x1 = [1 / math.log(math.log(N)) for N in step]; x2 = [1 / math.log(N) for N in step] ce = [yi / xi for yi, xi in zip(y, x1)]; m = sum(ce) / 4 print(f"H0 one-parameter law: c_eff spread {min(ce):.5f}..{max(ce):.5f}, max dev from mean {max(abs(c-m) for c in ce)/m*100:.2f}% (pass needs <= 2%) ->", "PASS" if max(abs(c-m) for c in ce) / m <= 0.02 else "FAIL") c = sum(a * b for a, b in zip(x1, y)) / sum(a * a for a in x1) res1 = [yi - c * a for yi, a in zip(y, x1)] s11 = sum(a*a for a in x1); s12 = sum(a*b for a, b in zip(x1, x2)); s22 = sum(b*b for b in x2) t1 = sum(a*yi for a, yi in zip(x1, y)); t2 = sum(b*yi for b, yi in zip(x2, y)); det = s11*s22 - s12*s12 ca, cb = (t1*s22 - t2*s12) / det, (s11*t2 - s12*t1) / det res2 = [yi - ca*a - cb*b for yi, a, b in zip(y, x1, x2)] N12 = 10**12; ll12, l12 = math.log(math.log(N12)), math.log(N12); obs12 = rows[N12][1] / rows[N12][0] if N12 in rows else None print(f"fit1: 1/2-F/V = c/lnlnN, c={c:.6f}, max|res|={max(map(abs,res1)):.2e}, predicts F/V(1e12)={0.5-c/ll12:.6f}") print(f"fit2: 1/2-F/V = c/lnlnN + c'/lnN, c={ca:.6f}, c'={cb:.6f}, max|res|={max(map(abs,res2)):.2e}, predicts F/V(1e12)={0.5-ca/ll12-cb/l12:.6f}; limit 1/2") print(f"P(1e12)={P(N12):.6f} (no fitted parameter); measured 1e12: {obs12:.6f}") dev = {N: rows[N][1]/rows[N][0] - P(N) for N in (10**9, 10**10)} ok = all(abs(d) <= 1e-4 for d in dev.values()) and rows[10**10][1]/rows[10**10][0] < rows[10**9][1]/rows[10**9][0] print("H1:", "PASS" if ok else "FAIL/INCONCLUSIVE", {f"1e{round(math.log10(k))}": f"{d:+.2e}" for k, d in dev.items()})