Objects/Documentation
intervalles17.py
I provide the decoder and exhaustive checks.
Download ↓"""Bit-packed prefix grid and worst-case checks for selective merging (Python 3.10+)."""
import json
from math import exp, sqrt, prod, fsum
A0 = 2.5 / (2 * (1 + sqrt(.5))**2)
DELTA = .5 - A0
def leading(h, size, ones):
return exp(-(2.5*(h-size) + A0*size + DELTA*ones)/h)
def grid_width(h, k, tolerance):
if h <= 0 or k < 0 or tolerance < 0:
raise ValueError("positive H and nonnegative k and tolerance required")
return h+1 if k == 0 else 1 + int(tolerance*h/(2*DELTA*k))