"""Render certified rational endpoints outwards at six decimal places for the PDF.""" from fractions import Fraction as Q from pathlib import Path import json root=Path(__file__).resolve().parents[1] records=json.loads((root/'evidence'/'example_certificates.json').read_text()) labels={'phi_fair_q2':r'$\varphi$, fair iid', 'phi_markov_q2':r'$\varphi$, zero-edge Markov', 'salem_fair_q2':r'Salem, fair iid', 'salem_markov_q2':r'Salem, zero-edge Markov', 'salem_fair_q3':r'Salem, fair iid', 'variable_phi_q2':r'$\varphi$, unequal clocks', 'hidden_clock_q2':r'$\varphi$, three-state hidden', 'mixture_cusp_q2':r'Base $2$, stationary mixture', 'salem_correlated_q2':r'Salem, positive correlated', 'phi_correlated_q2':r'$\varphi$, positive correlated'} def endpoint(x,up=False): scaled=Q(x)*10**6 v=-(-scaled.numerator//scaled.denominator) if up else scaled.numerator//scaled.denominator return f'{v//10**6}.{v%10**6:06d}' rows=[] for record in records: if record['name'] not in labels: continue c=record['certificate'];lo,hi=c['interval_nats_per_branch'] rows.append(f"{labels[record['name']]} & {c['depth']} & {c['order']} & {endpoint(lo)} & " f"{endpoint(hi,True)} & {c['diagnostics']['max_layer_states']} \\\\") text='\n'.join([r'\begin{table}[htbp]',r'\centering\small',r'\setlength{\tabcolsep}{4pt}', r'\begin{tabular}{lrrrrr}',r'\toprule', r'Source / base & $n$ & $q$ & Lower & Upper & Peak states\\',r'\midrule']+rows+ [r'\bottomrule',r'\end{tabular}', r'\caption{Exact-rational rate certificates, displayed outwards to six decimal places. ' r'Rates are in nats per branch; peak states are observed layer sizes, not asymptotic bounds.}', r'\label{tab:certs}',r'\end{table}']) (root/'manuscript'/'certificate_table.tex').write_text(text+'\n')