# bias1963.py -- job #1963: a new finite statistic with a pre-registered falsifier. # # QUESTION. Return #1032 (route 37) showed that every "parity class ratio" on the twin tile reduces to the Liouville mean over # admissible slots, s = (sum lambda(n) + sum lambda(n+2))/A, and that s was negative at all 11067 period-aligned cutoffs to # 3.3e7 with s*sqrt(N) flat. The retained censuses (slot counts, gap ladders) carry no sign information and cannot decide # anything about it. STATISTIC: the tile-restricted Liouville bias # S_x(N) = sum_{n < N, gcd(n(n+2), x#) = 1} (lambda(n) + lambda(n+2)), beta_x(N) = S_x(N)/sqrt(N), # at period-aligned cutoffs N = k*x#, compared with (a) an independent random-sign control on the same admissible slots # (seed 20260918; sd sqrt(2 A_N)) and (b) the unrestricted Liouville sum L(N) = sum_{n= 0. # F2 (scale): the log-log OLS slope of |S_x(N)| against N over the cutoffs with N in [1e6, 1e8] lies in [0.35, 0.65] # at every level. Falsified by a slope outside that band (a slope near 1 would mean a density-scale bias, i.e. the # sifted set's Liouville mean does not tend to 0 in the accessible range; a slope near 0 would mean the bias is a # bounded fluctuation). # F3 (amplification): S_x(N) / (2 (A_N/N) L(N)) > 1 at the final cutoff of each level, i.e. sifting amplifies the # unrestricted negative bias rather than merely diluting it. Falsified by a ratio <= 1 (or by L(N) >= 0 there). # CONTROL: the random-sign S_ctrl(N)/sqrt(2 A_N) at the same cutoffs should behave as a standard normal (|z| < 4 at all # cutoffs except a control-compatible handful); the measured z = S_x(N)/sqrt(2 A_N) is reported beside it. # SCALE at which the effect is visible: at N = 2.3e7, x = 11, S ~ -1.3e4 against control sd ~ 1.6e3 (z ~ -8); every level # and every decade of N should show |z| >> 4 if the effect is real. # Timing goes to stderr only. import sys, json, math, time import numpy as np t0 = time.time() N = 100_000_000 NL = N + 3 isp = np.ones(NL, dtype=bool); isp[:2] = False for p in range(2, int(NL ** 0.5) + 1): if isp[p]: isp[p * p::p] = False primes = np.flatnonzero(isp) lam = np.ones(NL, dtype=np.int8) for p in primes: p = int(p); q = p while q < NL: lam[q::q] *= -1; q *= p print(f'lam sieve {time.time() - t0:.0f}s, {len(primes)} primes', file=sys.stderr) # gates assert int(np.count_nonzero(isp[:1_000_001 - 2] & isp[2:1_000_001])) == 8169 def omega(n): c = 0; d = 2 while d * d <= n: while n % d == 0: n //= d; c += 1 d += 1 return c + (1 if n > 1 else 0) assert all(int(lam[v]) == (-1) ** omega(v) for v in (2, 12, 30, 97, 1024, 99991, 1_000_003, 99_999_989, 17 * 19 * 23 * 29 * 31)) lam_n = lam[:N]; lam_n2 = lam[2:N + 2] Lfull = np.cumsum(lam_n, dtype=np.int64) # L(N) at every N (needed only at cutoffs) rng = np.random.default_rng(20260918) out = {'N': N, 'seed': 20260918, 'levels': {}} for x in (11, 13, 17): t1 = time.time() M = math.prod(p for p in (2, 3, 5, 7, 11, 13, 17) if p <= x); K = N // M; n = np.arange(N, dtype=np.int64) adm = np.ones(N, dtype=bool) for p in (2, 3, 5, 7, 11, 13, 17): if p <= x: adm &= (n % p != 0) & ((n + 2) % p != 0) del n A_per = int(adm[:M].sum()); assert A_per == math.prod(p - 2 for p in (3, 5, 7, 11, 13, 17) if p <= x) v = (adm * (lam_n.astype(np.int16) + lam_n2.astype(np.int16)))[:K * M].reshape(K, M).sum(axis=1, dtype=np.int64) S = np.cumsum(v) # S_x(k M) ctrl_signs = rng.choice(np.array([-1, 1], dtype=np.int8), size=N) vc = (adm * (ctrl_signs.astype(np.int16) + np.roll(ctrl_signs, -2).astype(np.int16)))[:K * M].reshape(K, M).sum(axis=1, dtype=np.int64) Sc = np.cumsum(vc) ks = np.arange(1, K + 1); Nk = ks * M; Ak = ks * A_per Lk = Lfull[Nk - 1] z = S / np.sqrt(2 * Ak); zc = Sc / np.sqrt(2 * Ak) sel = Nk >= 1_000_000 slope = float(np.polyfit(np.log(Nk[sel].astype(float)), np.log(np.abs(S[sel]).astype(float)), 1)[0]) if np.all(S[sel] != 0) else None amp = float(S[-1] / (2 * (Ak[-1] / Nk[-1]) * Lk[-1])) if Lk[-1] != 0 else None snap = [int(kk) for kk in sorted(set([1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, K])) if kk <= K] lev = {'x': x, 'M': M, 'K': K, 'A_per_period': A_per, 'F1_sign_persistence': {'negative_cutoffs': int((S < 0).sum()), 'nonnegative_cutoffs': int((S >= 0).sum()), 'first_nonnegative_k': (int(ks[S >= 0][0]) if (S >= 0).any() else None), 'pass': bool((S < 0).all())}, 'F2_loglog_slope_1e6_1e8': slope, 'F2_pass': (slope is not None and 0.35 <= slope <= 0.65), 'F3_amplification_final': amp, 'F3_pass': (amp is not None and amp > 1), 'L_full_at_final_cutoff': int(Lk[-1]), 'S_at_final_cutoff': int(S[-1]), 'control': {'max_abs_z': float(np.abs(zc).max()), 'cutoffs_abs_z_gt_4': int((np.abs(zc) > 4).sum()), 'mean_z': float(zc.mean())}, 'measured_z': {'min': float(z.min()), 'max': float(z.max()), 'cutoffs_abs_z_gt_4': int((np.abs(z) > 4).sum()), 'total_cutoffs': int(K)}, 'beta_times_sqrtN_range_last_decade': [float((S[sel] / np.sqrt(Nk[sel])).min()), float((S[sel] / np.sqrt(Nk[sel])).max())], 'series': [{'k': kk, 'N': int(kk * M), 'A': int(kk * A_per), 'S': int(S[kk - 1]), 'beta': float(S[kk - 1] / math.sqrt(kk * M)), 'z': float(z[kk - 1]), 'z_ctrl': float(zc[kk - 1]), 'L_full': int(Lk[kk - 1]), 'amplification': (float(S[kk - 1] / (2 * (kk * A_per / (kk * M)) * Lk[kk - 1])) if Lk[kk - 1] != 0 else None)} for kk in snap]} out['levels'][str(x)] = lev print(f'x={x} done {time.time() - t1:.0f}s', file=sys.stderr) json.dump(out, open('bias1963.json', 'w'), indent=1) for x, lev in out['levels'].items(): print(f"x={x} M={lev['M']} K={lev['K']} cutoffs; F1 sign persistence: {lev['F1_sign_persistence']}") print(f" F2 log-log slope |S| vs N on [1e6,1e8]: {lev['F2_loglog_slope_1e6_1e8']:.4f} pass={lev['F2_pass']}; F3 amplification at N=1e8: {lev['F3_amplification_final']} pass={lev['F3_pass']} (L(N)={lev['L_full_at_final_cutoff']}, S={lev['S_at_final_cutoff']})") print(f" control: {lev['control']}; measured z: {lev['measured_z']}; beta = S/sqrt(N) range over last decade: {lev['beta_times_sqrtN_range_last_decade']}") for r in lev['series']: print(f" k={r['k']:>6} N={r['N']:>10} A={r['A']:>8} S={r['S']:>8} beta={r['beta']:+.3f} z={r['z']:+.2f} z_ctrl={r['z_ctrl']:+.2f} L(N)={r['L_full']:>7} amp={r['amplification']}") print('VERDICT:', 'all pre-registered falsifiers survive' if all(l['F1_sign_persistence']['pass'] and l['F2_pass'] and l['F3_pass'] for l in out['levels'].values()) else 'at least one falsifier FIRED (see rows)')