# decryption_complete: false # source: /Voynich/Voynich_PORTABLE_ANONYMOUS_ROLE_BREAKTHROUGH_037_042_reproducibility.zip!/run_bandwidth # stated_sha256: c8570bf07d166b6fde346e27117d2f7249f6ff276443272c2e62f984e1e473f0 # matches_stated_sha256: false # pdf_pages: 724-725 # note: The stated SHA-256 is the digest printed in the PDF. # The PDF page extract follows the form feed. decryption_complete stays false. run_bandwidth_maxstat_040.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 1 run_bandwidth_maxstat_040.py Source: /Voynich/Voynich_PORTABLE_ANONYMOUS_ROLE_BREAKTHROUGH_037_042_reproducibility.zip!/run_bandwidth _maxstat_040.py SHA-256: c8570bf07d166b6fde346e27117d2f7249f6ff276443272c2e62f984e1e473f0 !/usr/bin/env python3 """BANDWIDTH-MAXSTAT-040: selection-corrected vertical band widths 1-5.""" from pathlib import Path from scipy.special import comb import hashlib,json import numpy as np,pandas as pd import run_geometric_expansion_link_030 as g30 import run_fifth_record_prospective_033 as p33 import run_anonymous_record_decompression_032 as d32 ROOT=Path(__file__).resolve().parent;OUT=ROOT/'bandwidth_maxstat_040';OUT.mkdir(exist_ok=True);KS=range( 1,6);REPS=20000;SEED=20260830 def exp(n,p,k):k=min(k,n);return 1-comb(n-p,k,exact=False)/comb(n,k,exact=False) if n-p>=k else 1. def distances(q):return [abs((c['box'][1]+c['box'][3])/2/837-q['qy']/837) for c in q['cand']] def gain(queries,k,shift=None): vals=[] for qi,q in enumerate(queries): n=len(q['cand']);pos=q['pos'] if shift is None else {(x+shift[qi])%n for x in q['pos']};top=set(sorted(range(n),key=lambda i:distances(q)[i])[:min(k,n)]);vals.append(int(bool(top&pos ))-exp(n,len(pos),k)) return float(np.mean(vals)) def main(): lb=g30.aligned_label_boxes();base=g30.aligned_prose_lines();add,_=p33.recover_unrestricted(base);coords ={**base,**add};qd={w:{(q['folio'],q['key']):q for q in g30.build(w,lb,coords)} for w in ('ZL','GC')};common=sorted(set(qd['ZL'])&set(qd['GC']));queries={w:[qd[w][x] for x in common] for w in qd};obs={w:{k:gain(queries[w],k) for k in KS} for w in queries};selected=max(KS,key=lambda k:np.mean([obs[w][k] for w in obs]));rng=np.random.default_rng(SEED);null={w:[] for w in queries} for _ in range(REPS): for w in queries: shifts=[int(rng.integers(len(q['cand']))) for q in queries[w]];null[w].append(max(gain(queries[w],k,s hifts) for k in KS)) p={w:(1+sum(x>=obs[w][selected] for x in null[w]))/(REPS+1) for w in queries};curve=[] for w in queries: for k in KS:curve.append({'witness':w,'band_width':k,'gain':obs[w][k],'selected':int(k==selected),'max stat_p_if_selected':p[w] if k==selected else None}) # Extract new records only under the globally selected width. old=pd.read_csv(ROOT/'gc_segmentation_recovery_035/five_record_anonymous_ledger.csv');oldphys={(r.folio ,int(r.zl_line),int(r.gc_line)) for r in old.itertuples()};new=[] for key in common: chosen={} for w in ('ZL','GC'): q=qd[w][key];ds=distances(q);top=sorted(range(len(ds)),key=lambda i:ds[i])[:selected];hits=[i for i in top if i in q['pos']];chosen[w]=(q,min(hits,key=lambda i:ds[i])) if hits else None if all(chosen.values()): zq,zi=chosen['ZL'];gq,gi=chosen['GC'];zc,gc=zq['cand'][zi],gq['cand'][gi];zr=[x for x in zc['payloads'] if x!=key[1]];gr=[x for x in gc['payloads'] if x!=key[1]];jac=d32.multiset_jaccard(zr,gr) ;lcs=d32.lcs_ratio(zr,gr);phys=(key[0],zc['line'],gc['line']) if phys not in oldphys and jac>=.5 and lcs>=.75:new.append({'record_id':f'{key[0]}:{zc["line"]}/{gc[" line"]}','folio':key[0],'zl_line':zc['line'],'gc_line':gc['line'],'keys':key[1],'zl_residual':' | '.join(zr),'gc_residual':' | '.join(gr),'multiset_jaccard':jac,'ordered_lcs_ratio':lcs}) nd=pd.DataFrame(new).drop_duplicates(['folio','zl_line','gc_line']) if new else pd.DataFrame(columns=old.columns);passed=all(p[w]<.05 and obs[w][selected]>0 for w in p) and len(nd)>=1;expanded=pd.concat([old,nd],ignore_index=True) if passed else old pd.DataFrame(curve).to_csv(OUT/'bandwidth_curve.csv',index=False);pd.DataFrame({'witness':np.repeat(lis t(null),REPS),'replicate':list(range(REPS))*len(null),'max_gain':sum([null[w] for w in null],[])}).to_csv(OUT/'maxstat_null.csv',index=False);nd.to_csv(OUT/'candidate_new_records.csv',index=F alse);expanded.to_csv(OUT/'promoted_ledger.csv',index=False) summary={'test':'BANDWIDTH-MAXSTAT-040','widths_tested':list(KS),'globally_selected_width':selected,'ob served_gains':obs,'maxstat_p':p,'candidate_new_records':len(nd),'promoted_records':len(expanded),'pass': run_bandwidth_maxstat_040.py VOYNICH RESEARCH ARCHIVE | 16 SEPTEMBER 2026 2 passed,'boundary':'Selection-corrected anonymous band retrieval; no plaintext or semantics.'};(OUT/'summary.json').write_text(json.dumps(summary,indent=2)) report=['# BANDWIDTH-MAXSTAT-040','',('**PASS — SIXTH RECORD PROMOTED**' if passed else '**FAIL / NOT PROMOTED**'),'','Band widths 1-5 were tested as one family. The globally selected width was charged against each witness\'s maximum null gain across all widths.','',f"- Selected width: {selected}",f"- ZL gain / max-stat p: {obs['ZL'][selected]:+.4f} / {p['ZL']:.6f}",f"- GC gain / max-stat p: {obs['GC'][selected]:+.4f} / {p['GC']:.6f}",f"- Candidate new records: {len(nd)}",f"- Promoted ledger records: {len(expanded)}",'','## Rule audit','',('EDGE HANDOFF strengthens to a selection-corrected band window; six rules remain.' if passed else 'No rule change; six remain.')] (OUT/'report.md').write_text('\n'.join(report));files=sorted(x for x in OUT.iterdir() if x.is_file() and x.name!='SHA256SUMS.txt');(OUT/'SHA256SUMS.txt').write_text('\n'.join(f'{hashlib.sha256(x.read_bytes ()).hexdigest()} {x.name}' for x in files)+'\n');print(json.dumps(summary,indent=2)) if __name__=='__main__':main()