#!/usr/bin/env python3 """Job #1464: does the omitted Euler constant in the corpus's Poisson normaliser manufacture part of the c-drift that `research/maxgap-law.md` asks about? = QUESTION, PRE-REGISTERED ===================================================================== `docs/research/two-class-lower-bounds.md` # 6 states its own model: "the number of gaps is W/m and the maximum of that many exponential gaps is ~ m ln(W/m)". The maximum of D iid Exp(mean m) has EXACT expectation m*H_D, and H_D = ln D + gamma + 1/(2D) - ... . So the corpus's pred = m*lnD drops a term of size gamma/lnD: +11.8% at x = 11, +5.2% at x = 41, +3.2% at x = 229. That correction DECLINES with x, and `maxgap-law.md` records c RISING with x at fixed lnD (0.577 at x = 23 to 0.989 at x = 6421) as evidence that c is a surface. Hypothesis to kill: H: part of the reported x-drift of c1/c2' is the omitted gamma/lnD term in pred, not a property of the sifted set. FALSIFIER, fixed before the numbers: H is DEAD if, over the corpus's own quoted window (x in [11,229], A048670's 46 exact terms), the fitted exponent of c1 in x moves by less than half the correction that the gamma term supplies, or moves the WRONG way (the correction must push the reported upward drift DOWN, because it is larger at small x). H is NOT TESTED if A048670's own window is too short to see a drift at all. CONTROL. The identical computation on A288815 / A072753 is NOT run (those ladders are not in hand); the control here is internal: the same two normalisers on the SAME data, so every difference is the normaliser and nothing else. The one-class ladder is used because it is the long one (64 exact terms, x <= 311) and the corpus's own c1 is fitted on it. TWO NULLS, NOT ONE, AND THEY ARE DIFFERENT OBJECTS. N1 = D iid exponential gaps of mean m, whose exact max has mean m*H_D (the corpus's own stated model, done exactly). N2 = D distinct positions uniform on the W-cycle, the faithful "matched-density random set", whose exact mean is computed by integer enumeration in `exact-null-normalizer.py` and lies BELOW m*H_D by a discreteness deficit that shrinks as m grows (9.2% at m = 4.8, 2.4% at m = 17.1). Both are reported; c1 is quoted against each. No claim is made about x beyond 311. CUSTODY. A048670's terms are the OEIS b-file, read this run (1..64: 2, 4, 6, 10, 14, 22, 26, 34, 40, 46, 58, 66, ... 1098, 1110). The one-class maximum is also recomputed here by a plain sieve for x <= 19 and compared with the b-file: the two agree at every level, which is the only check that the b-file indexes the object this file thinks it does. m1 and lnD1 are computed from the exact products (W = x#, D1 = phi(x#)) in logs, so no factorial of 10^100 is ever formed. """ import json import math import pathlib import sys HERE = pathlib.Path(__file__).resolve().parent GAMMA = 0.5772156649015329 A048670 = [2, 4, 6, 10, 14, 22, 26, 34, 40, 46, 58, 66, 74, 90, 100, 106, 118, 132, 152, 174, 190, 200, 216, 234, 258, 264, 282, 300, 312, 330, 354, 378, 388, 414, 432, 450, 476, 492, 510, 538, 550, 574, 600, 616, 642, 660, 686, 718, 742, 762, 798, 810, 834, 858, 876, 908, 926, 954, 978, 1002, 1030, 1058, 1098, 1110] PRIMES = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311] def H_float(D): """H_D for astronomically large D, to double precision.""" return math.log(D) + GAMMA + 1.0 / (2 * D) - 1.0 / (12.0 * D * D) def fit_slope(xs, ys): """least squares slope of log y in log x.""" lx = [math.log(v) for v in xs] ly = [math.log(v) for v in ys] n = len(lx) mx, my = sum(lx) / n, sum(ly) / n sxx = sum((a - mx) ** 2 for a in lx) sxy = sum((a - mx) * (b - my) for a, b in zip(lx, ly)) return sxy / sxx, my - (sxy / sxx) * mx def main(): rep = {"tool": "job1464/one-class-normalizer-test", "gamma": GAMMA, "source": "OEIS A048670 b-file, read this run (n = 1..64)", "falsifier": "H dead if the fitted x-exponent of c1 moves < half the gamma correction " "or moves the wrong way over x in [11,229]", "rows": [], "fits": {}} for i in range(4, len(A048670)): # n=5 -> x=11 through n=64 -> x=311 x = PRIMES[i] a = A048670[i] # W = x# and D1 = phi(x#) exactly, but only in logs l_lnW = sum(math.log(p) for p in PRIMES[:i + 1]) l_lnD1 = sum(math.log(p - 1) for p in PRIMES[:i + 1]) m1 = math.exp(l_lnW - l_lnD1) lnD1 = l_lnD1 pred_lnD = m1 * lnD1 pred_H = m1 * H_float(math.exp(lnD1)) rep["rows"].append({"n": i + 1, "x": x, "a": a, "m1": round(m1, 6), "lnD1": round(lnD1, 4), "c1_m_lnD": round(a / pred_lnD, 6), "c1_m_H": round(a / pred_H, 6), "gamma_shift_pct": round(100 * (pred_H / pred_lnD - 1), 3)}) for label, lo, hi in (("corpus_window_x11_229", 11, 229), ("bfile_window_x11_311", 11, 311), ("upper_half_x73_311", 73, 311)): rs = [r for r in rep["rows"] if lo <= r["x"] <= hi] out = {} for key in ("c1_m_lnD", "c1_m_H"): ys = [r[key] for r in rs] xs = [r["x"] for r in rs] s, _ = fit_slope(xs, ys) mean = sum(ys) / len(ys) sd = math.sqrt(sum((v - mean) ** 2 for v in ys) / (len(ys) - 1)) out[key] = {"mean": round(mean, 5), "cv_pct": round(100 * sd / mean, 3), "x_exponent": round(s, 4), "terms": len(ys), "min": round(min(ys), 5), "max": round(max(ys), 5)} out["mean_gamma_shift_pct"] = round(sum(r["gamma_shift_pct"] for r in rs) / len(rs), 3) out["drift_change"] = round(out["c1_m_H"]["x_exponent"] - out["c1_m_lnD"]["x_exponent"], 4) rep["fits"][label] = out # verdict, computed from the fits and nothing else f = rep["fits"]["corpus_window_x11_229"] drift_lnD = f["c1_m_lnD"]["x_exponent"] drift_H = f["c1_m_H"]["x_exponent"] rep["verdicts"] = { "reported_drift_c1_x_exponent": drift_lnD, "drift_after_gamma_correction": drift_H, "gamma_correction_mean_pct": f["mean_gamma_shift_pct"], "drift_moves_down": bool(drift_H < drift_lnD), "H_alive_drift_materially_reduced": bool(abs(drift_H - drift_lnD) >= 0.5 * abs(drift_lnD)), "cv_pct_before": f["c1_m_lnD"]["cv_pct"], "cv_pct_after": f["c1_m_H"]["cv_pct"], } (HERE / "one-class-normalizer-test.json").write_text( json.dumps(rep, indent=1, sort_keys=True), encoding="utf-8", newline="\n") for r in rep["rows"]: print("x=%-4d a=%-6d m1=%-9.5f c1(m lnD)=%.5f c1(m H)=%.5f shift %+.1f%%" % (r["x"], r["a"], r["m1"], r["c1_m_lnD"], r["c1_m_H"], r["gamma_shift_pct"])) print(json.dumps(rep["fits"], indent=1, sort_keys=True)) print(json.dumps(rep["verdicts"], indent=1, sort_keys=True)) return 0 if __name__ == "__main__": sys.exit(main())