#!/usr/bin/env python3 """Analysis over the already-measured tiles: no new computation.""" import json import math import os import sys W = os.path.dirname(os.path.abspath(__file__)) TILES = [13, 17, 19, 23, 29, 31] R = {} for x in TILES: p = os.path.join(W, "t%d.json" % x) if os.path.exists(p): R[x] = json.load(open(p, encoding="utf-8")) xs = sorted(R) out = [] w = out.append w("== 1. the repeat core R/E_rep over the whole reachable ladder ==") w("%3s %16s %14s %9s %9s" % ("x", "D", "R", "E_rep", "R/E_rep")) for x in xs: r = R[x]["repeat"] w("%3d %16d %14d %14.1f %9.5f" % (x, R[x]["D"], r["R"], r["E_repeat"], r["ratio"])) w("") w("increments (the route only had T23/T29/T31 and called this 'stable to 0.6%'):") for i in range(1, len(xs)): a, b = xs[i - 1], xs[i] ra, rb = R[a]["repeat"]["ratio"], R[b]["repeat"]["ratio"] w(" T%-2d -> T%-2d x%-8.3f ratio %+.5f (%+.3f%%) D x%.1f" % (a, b, rb / ra, rb - ra, 100 * (rb / ra - 1), R[b]["D"] / R[a]["D"])) w("") w("least-squares slope of R/E_rep on log(D), over the four largest tiles:") big = [x for x in xs if x >= 23] lx = [math.log(R[x]["D"]) for x in big] ly = [R[x]["repeat"]["ratio"] for x in big] n = len(lx) mx, my = sum(lx) / n, sum(ly) / n slope = sum((a - mx) * (b - my) for a, b in zip(lx, ly)) / sum((a - mx) ** 2 for a in lx) icpt = my - slope * mx d37 = 6226553025 * 35 pred = icpt + slope * math.log(d37) w(" slope = %+.6f per ln D -> R/E_rep(T37) predicted %.5f (pre-registered band [0.637, 0.648])" % (slope, pred)) w(" one-step multiplicative model on the last step (x%.5f) -> %.5f" % (R[31]["repeat"]["ratio"] / R[29]["repeat"]["ratio"], R[31]["repeat"]["ratio"] ** 2 / R[29]["repeat"]["ratio"])) w("") w("== 2. per-gap-value repeat ratios, from folds whose kill class is a SINGLETON ==") w(" (for such a fold K2_p is exactly R_g and E_p is exactly the exchangeable E_g of") w(" that one gap value, so the measurement is free: it is already in the spectrum)") w("%5s %6s %14s %12s %10s %8s %9s" % ("x", "p", "gap g", "count h_g", "R_g", "E_g", "ratio")) rows = [] for x in xs: for v in R[x]["folds"]: if len(v["support"]) == 1 and v["E"] > 0: rows.append((x, v["p"], v["support"][0], v["m"], v["K2"], v["E"], v["K2"] / v["E"])) for r in rows[:40]: w("%5d %6d %14d %12d %10d %8.1f %9.5f" % r) if len(rows) > 40: w(" ... %d singleton folds in total" % len(rows)) w("") w("== 3. how the global 0.64 core compares to its own per-value pieces ==") for x in xs: rr = R[x]["repeat"] sing = [r for r in rows if r[0] == x] if sing: w(" T%-2d global R/E_rep = %.5f | singleton folds: ratio min %.5f max %.5f (%d values)" % (x, rr["ratio"], min(r[6] for r in sing), max(r[6] for r in sing), len(sing))) else: w(" T%-2d global R/E_rep = %.5f | no singleton fold available" % (x, rr["ratio"])) w("") w("== 4. Lambda at a FIXED fold p, down the ladder (the deceleration claim) ==") for p in (23, 29, 31, 37): seq = [] for x in xs: f = {v["p"]: v for v in R[x]["folds"]} if p in f: seq.append((x, f[p]["m"], f[p]["K2"], f[p]["lambda"], f[p]["z"])) if not seq: continue w(" p = %d" % p) prev = None for x, m, k2, lam, z in seq: note = "" if prev is None or prev == 0 else " x%.3f" % (lam / prev) w(" T%-2d m=%12d K2=%10d Lambda=%.5f z=%.1f%s" % (x, m, k2, lam, z, note)) prev = lam w("") w("== 5. the p-collapse: which folds have K2 = 0, and is it a support-size effect ==") for x in (23, 29, 31): f = R[x]["folds"] zero = [v["p"] for v in f if v["K2"] == 0] small = [v["p"] for v in f if v["K2"] > 0 and v["K2"] < 10] w(" T%-2d K2=0 at p in %s" % (x, zero[:18])) w(" K2 in 1..9 at p in %s" % (small[:18])) w(" max support size among K2=0 folds: %d ; among K2>0 folds: %d" % (max([len(v["support"]) for v in f if v["K2"] == 0] or [0]), max([len(v["support"]) for v in f if v["K2"] > 0] or [0]))) print("\n".join(out))