// Reads MAIN TABLE and IDENTITY (12) rows from the served script's embedded block (j=16..38). // Prints rho=|D_y|/(x/log^2 x), D_y/x, (T1/x-C2), residual D_y/x+(T1/x-C2), and discrimination factor 0.16/|D_y/x|. import fs from 'fs'; const L = fs.readFileSync(process.argv[2], 'utf8').split('\n'); const s = L.findIndex(l => l.startsWith('// OUTPUT')); const rows = L.slice(s).filter(l => /^\/\/ \d+ \|/.test(l)).map(l => l.slice(3).split(' | ')); const main = {}, id = {}; for (const r of rows) { if (r.length === 14) main[+r[0]] = { x: +r[1], D: +r[7] }; else if (r.length === 9) id[+r[0]] = { T1: +r[2] }; } console.log('j | D_y/x | rho | T1/x-C2 | D_y/x+(T1/x-C2) | 0.16/|D_y/x|'); const out = []; for (let j = 16; j <= 38; j++) { const m = main[j], t = id[j]; const lx = j * Math.log(2); const rho = Math.abs(m.D) * lx * lx; const res = m.D + t.T1; out.push({ j, D: m.D, rho, T1: t.T1, res }); console.log([j, m.D, rho.toFixed(3), t.T1, res.toExponential(2), (0.16 / Math.abs(m.D)).toFixed(0)].join(' | ')); } const band = out.filter(o => o.j >= 26 && o.j <= 34); const mx = Math.max(...band.map(o => o.rho)); console.log('max rho j=26..34:', mx.toFixed(3), '; min rho all j<=34:', Math.min(...out.filter(o => o.j <= 34).map(o => o.rho)).toFixed(3), '; max rho j<=34:', Math.max(...out.filter(o => o.j <= 34).map(o => o.rho)).toFixed(3)); const r38 = out.find(o => o.j === 38), r34 = out.find(o => o.j === 34); console.log('pre-registered test at j=38: rho38>max?', r38.rho > mx, '; D/x negative?', r38.D < 0, '; |D/x| >= 4x j34?', Math.abs(r38.D) >= 4 * Math.abs(r34.D), '=> informative:', r38.rho > mx && r38.D < 0 && Math.abs(r38.D) >= 4 * Math.abs(r34.D)); const big = out.filter(o => o.j >= 26); const ratio = big.map(o => Math.abs(o.res) / Math.abs(o.D)); console.log('j>=26: median |res|/|D_y/x| =', ratio.sort((a, b) => a - b)[Math.floor(ratio.length / 2)].toFixed(3), '; max |res| =', Math.max(...big.map(o => Math.abs(o.res))).toExponential(2), '; max |D_y/x| =', Math.max(...big.map(o => Math.abs(o.D))).toExponential(2)); const n = big.length, mD = big.reduce((a, o) => a + o.D, 0) / n, mT = big.reduce((a, o) => a + o.T1, 0) / n; const c = big.reduce((a, o) => a + (o.D - mD) * (o.T1 - mT), 0) / Math.sqrt(big.reduce((a, o) => a + (o.D - mD) ** 2, 0) * big.reduce((a, o) => a + (o.T1 - mT) ** 2, 0)); console.log('corr(D_y/x, T1/x-C2) over j=26..38:', c.toFixed(4));