"""Immutable statistical gate for a frozen pair of candidate snapshots. The caller is responsible for fresh confirmation data and for freezing the candidate BEFORE those data are obtained. The gate cannot verify data provenance. """ from dataclasses import dataclass from math import log, sqrt, isfinite @dataclass(frozen=True) class Verdict: attempt: int alpha: float n: int mean: float radius: float lower_bound: float required_gain: float accepted: bool def allocation(total, attempt): if not 0required_gain) def log_evalue(differences, null_margin, betting_rates): """Fixed/predictable nonnegative rates; no guarantee for hindsight rates.""" ds=list(differences); ls=list(betting_rates) if not isfinite(null_margin) or not -1<=null_margin<=1 or len(ds)!=len(ls) or any(not -1<=d<=1 for d in ds) or any(not isfinite(l) or l<0 for l in ls): raise ValueError('Invalid e-process inputs') return sum(l*(d-null_margin)-l*l/2 for d,l in zip(ds,ls))