repair-20261016T061049Z-prose.py

back to table · edit · history · where entries came from · files · download

2191 bytes, as of the version from 2026-10-16 06:19 (current). Recorded here, not run.

"""Generate the T454 prose repair from the saved API document; no API writes."""
import copy
import difflib
import json
from pathlib import Path
p=Path(__file__).resolve().parent
before=json.loads((p/'repair-20261016T061049Z-before.json').read_text())
after=copy.deepcopy(before)
after['Data properties']['complete-note']=(
 r'it holds every pair with $\nu\in\{1,2,\ldots,30,40,50,60,100\}$ and '
 r'$p\in\{1/200,1/100,1/40,1/20,1/10,1/4,1/2,3/4,9/10,19/20,39/40,99/100,199/200,999/1000\}$. '
 r'The six cumulative probabilities $9/10,19/20,39/40,99/100,199/200,999/1000$ are those tabulated in CITE{NISTCritical}. '
 r'The stored selection also includes five complementary probabilities giving negative quantiles, the quartiles and the median. '
 r'The stored entries include $p=999/1000$ but omit its complement $p=1/1000$. '
 r'The degrees of freedom cover small samples and selected larger reference rows, matching HREF{Quantiles_of_the_chi-squared_distribution}[the chi-squared quantile table].')
after['Data properties']['parameter selection'] = (
 r'The probability selection uses the six cumulative probabilities in CITE{NISTCritical}, five complementary probabilities giving negative quantiles, the quartiles and the median. '
 r'The stored entries include $p=999/1000$ but omit its complement $p=1/1000$.')
after['Comments']['comment-probabilities']=(
 r'The probability labels are exact rationals in lowest terms. Thus $p=19/20$ is the familiar probability $0.95$, and $p=199/200$ is $0.995$.')
assert after['Numbers']==before['Numbers']
assert list(after['Parameters'])==list(before['Parameters'])==['nu','p']
assert after['Data properties']['digits']=='100'
(p/'T454-proposed.json').write_text(json.dumps(after,indent=2)+'\n')
diff=''.join(difflib.unified_diff(json.dumps(before,indent=2).splitlines(True),json.dumps(after,indent=2).splitlines(True),fromfile='live-before',tofile='proposed'))
(p/'T454-proposed.diff').write_text(diff)
print('COMPLETE NOTE\n'+after['Data properties']['complete-note'])
print('\nPROBABILITY COMMENT\n'+after['Comments']['comment-probabilities'])
print('\nRETAINED AUDIT-REQUIRED SELECTION NOTE\n'+after['Data properties']['parameter selection'])