"""Exact finite observation-unit example; no device measurements.""" from fractions import Fraction import json from pathlib import Path import sys STATES = [False] * 5 + [True] * 5 COUNTS = [1, 0, 0, 0, 0, 2, 2, 2, 2, 1] def summarize(states, counts): if not states or len(states) != len(counts): raise ValueError("Nonempty equally sized slot vectors required") if any(type(x) is not bool for x in states): raise ValueError("States must be booleans") if any(type(x) is not int or x < 0 for x in counts): raise ValueError("Counts must be nonnegative integers") populations = ( ("time", "All equal-duration slots", sum(states), len(states)), ("nonempty", "Nonempty timestamps", sum(s and n > 0 for s, n in zip(states, counts)), sum(n > 0 for n in counts)), ("event", "Individual arrivals", sum(n for s, n in zip(states, counts) if s), sum(counts)), ) return [{"id": key, "unit": unit, "high": high, "total": total, "fraction": str(Fraction(high, total)) if total else None} for key, unit, high, total in populations] def result(): return {"schema_version": 1, "kind": "synthetic-exact-arithmetic", "generated_on": "2026-11-19", "slot_duration_ms": 1, "states_high": STATES, "arrivals_per_slot": COUNTS, "rows": summarize(STATES, COUNTS), "assumptions": ["One complete ten-slot cycle; all slots have equal duration.", "State is an exogenous label fixed throughout a slot, not inferred queue occupancy.", "All arrivals in a slot see that slot's label; multiplicity is retained.", "No missing events, timeouts, sampling or fitted parameters.", "Fractions describe this constructed cycle, not confidence bounds or device behavior."]} if __name__ == "__main__": target = Path(__file__).with_name("results.json") data = result() if "--check" in sys.argv: if json.loads(target.read_text()) != data: raise ValueError("Generated results differ") else: target.write_text(json.dumps(data, indent=2) + "\n") print(json.dumps(data["rows"]))