#!/usr/bin/env node // job66-anchored-pairs.js (2026-09-11, solveathome job #66, handle Benjaminsen) // QUESTION. On the anchored measure (r uniform on the Natal@5 comb N inside // [0, W), W = x#), which pairs of strike events are EXACTLY independent? // Suen's inequality (Janson 1998, Remark 3) needs a dependency graph in the // strong sense; if no cross-prime pair is exactly independent, the only // admissible graph is the complete one. `history/staging/import-suen.md` §5 // asserts completeness; this script computes it at @11..@23. // Objects from paper/anchored-note.md §1: comb r ≡ 11,17 (mod 30), r mod p ∉ // {0, p−2} for 7 ≤ p ≤ x; y = largest prime ≤ √(W+2); scour primes x < q ≤ y; // A_q^L = {q | r}, A_q^R = {q | r+2}. Independent implementation: multiples of // each q are walked directly (no primality sieve), so L0, R0, S0 come out as // a by-product and are compared with import-suen-01-transfer.js PART A. 'use strict'; function primesUpTo(n){const s=new Uint8Array(n+1),o=[];for(let i=2;i<=n;i++){if(!s[i]){o.push(i);for(let j=i*i;j<=n;j+=i)s[j]=1;}}return o;} const LEVELS=(process.argv[2]?process.argv[2].split(',').map(Number):[11,13,17,19,23]); console.log('job66-anchored-pairs: exact pairwise (in)dependence of strike events on the anchored measure'); for(const x of LEVELS){ const t0=Date.now(); const base=primesUpTo(x).filter(p=>p>=7); let W=30; for(const p of base) W*=p; const Nbar=2*base.reduce((a,p)=>a*(p-2),1); const root=Math.floor(Math.sqrt(W+2)); const y=primesUpTo(root).filter(p=>p>2).pop(); const scour=primesUpTo(y).filter(q=>q>x); const K=scour.length; const E=2*K; // slots: r = 30k+11 -> 2k, r = 30k+17 -> 2k+1 const nslot=2*(W/30); const natal=new Uint8Array(nslot); let Ncount=0; for(let k=0;k{const m=r%30; if(m!==11&&m!==17) return -1; const s=2*Math.floor(r/30)+(m===17?1:0); return natal[s]?s:-1;}; // pass 1: count events per slot; marginals const cnt=new Uint8Array(nslot); const marg=new Float64Array(E); const walk=(fn)=>{for(let i=0;i=0) fn(s,2*i); s=slotOf(m-2); if(s>=0) fn(s,2*i+1);} }}; walk((s,e)=>{cnt[s]++; marg[e]++;}); const off=new Int32Array(nslot+1); for(let s=0;s{ev[off[s]+fill[s]++]=e;}); // anchored counts as by-product let L0=0,R0=0,S0=0; for(let s=0;s>1)===(v>>1); const J=joint[u*E+v]; const pr=marg[u]*marg[v]; if(same){within++; if(J!==0) withinNonzero++; continue;} cross++; if(J*Nbar===pr) indep++; if(J===0) zeroJoint++; if(pr>0&&J>0){ const dev=J*Nbar/pr-1; nRatio++; sumAbsDev+=Math.abs(dev); if(dev>0)posDev++; else negDev++; if(Math.abs(dev)>maxDev){maxDev=Math.abs(dev); maxDevPair=[scour[u>>1],(u&1)?'R':'L',scour[v>>1],(v&1)?'R':'L',J,marg[u],marg[v]];} } } // marginal deviation from 1/q let maxMarg=0; for(let e=0;e>1]; const dev=Math.abs(marg[e]*q/Nbar-1); if(dev>maxMarg) maxMarg=dev; } // pairs with q q' <= W (the "nearly independent" regime the proposal's referee names) let smallProd=0, smallIndep=0; for(let i=0;idmaxA) dmaxA=d; } const t2A=-muA+DeltaA*Math.exp(2*dmaxA), t3A=-Math.min(muA*muA/(8*DeltaA), muA/(6*dmaxA), muA/2), t8A=1-Delta0StarA*Math.exp(DeltaStarA); console.log(`\n@${x}: W=${W} N̄=${Nbar} y=${y} K=${K} events=${E} L0=${L0} R0=${R0} S0=${S0}`); console.error(`@${x}: elapsed ${((Date.now()-t0)/1000).toFixed(1)} s`); console.log(` within-prime pairs ${within}, with nonzero joint count ${withinNonzero} (mutual exclusion holds iff 0)`); console.log(` cross-prime pairs ${cross}: exactly independent ${indep}; joint count zero ${zeroJoint}`); console.log(` prime pairs with q·q' ≤ W: ${smallProd} (×4 event pairs = ${4*smallProd}), of which exactly independent ${smallIndep}`); console.log(` max |P(A∧B)/(P(A)P(B)) − 1| over cross pairs with nonzero joint: ${(100*maxDev).toFixed(2)}% at ${maxDevPair?maxDevPair.slice(0,4).join(' '):'-'} (joint ${maxDevPair?maxDevPair[4]:'-'}, marginals ${maxDevPair?maxDevPair[5]+','+maxDevPair[6]:'-'})`); console.log(` mean |dev| ${(100*sumAbsDev/Math.max(nRatio,1)).toFixed(3)}% over ${nRatio} pairs; positive ${posDev}, negative ${negDev}`); console.log(` max |q·P(A_q)/1 − 1| over events (marginal vs 1/q): ${(100*maxMarg).toFixed(3)}%`); console.log(` Suen inputs, anchored vs ν: μ ${muA.toFixed(5)} vs ${muNu.toFixed(5)} (ratio ${(muA/muNu).toFixed(4)}); Δ (unordered, one event per prime) ${DeltaA.toFixed(4)} vs ν-value ${DeltaNu.toFixed(4)} (ratio ${(DeltaA/DeltaNu).toFixed(4)}); Σ p_i p_j anchored ${DeltaProdA.toFixed(4)}`); console.log(` Suen (complete graph) with anchored inputs: δ=max_i Σ_{j≠i} p_j ${dmaxA.toFixed(5)}; Δ* ${DeltaStarA.toFixed(3)}; Δ₀* ${Delta0StarA.toFixed(3)}; Thm 2 exponent ${t2A>=0?'+':''}${t2A.toFixed(1)}; Thm 3 bound ${Math.exp(t3A).toFixed(5)}; Thm 8 bracket ${t8A.toExponential(2)}; truth S0/N̄ ${(S0/Nbar).toFixed(6)}`); }