FA-65126 / Epidemic compartment models / Open access
Windowed renewal-equation Rt estimate: window start · case 01
Rt lags one day behind and excludes the most recent incidence.
ROOT CAUSE
The estimation window is shifted one day into the past.
VERIFIED REPAIR
Restore the window start rule: `range(t - window + 1, t + 1)`.
Unsuccessful approach: Dropping day t shortens the window by one.
Case contract
weights[s-1] is the serial-interval weight at lag s>=1 (unnormalised); daily infection pressure Lambda_k = sum_s w_s*I[k-s]/sum of available weights (lags reaching before day 0 dropped); Rt = sum_{k=t-window+1..t} I_k / sum Lambda_k; None if the window reaches day 0, t is out of range or the denominator is zero; result rounded 6.
Why this case matters
Compartmental epidemic calculations drive outbreak forecasts, vaccine targets and hospital planning; a single wrong flow, rate conversion or boundary silently changes every downstream number.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(incidence, weights, t, window):
if window < 1 or t - window + 1 < 1 or t >= len(incidence):
return None
num = 0.0
den = 0.0
for k in range(t - window, t):
pressure = 0.0
mass = 0.0
for s in range(1, len(weights) + 1):
if k - s < 0:
break
pressure += weights[s - 1] * incidence[k - s]
mass += weights[s - 1]
if mass > 0:
pressure /= mass
num += incidence[k]
den += pressure
if den <= 0:
return None
return round(num / den, 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)],
[('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('regression: window starting on day 1', ([4, 6, 9, 12], [0.5, 0.5], 2, 2), 1.666667),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: growing outbreak | 2.614213 | 2.515432 | Failed |
| regression: declining outbreak | 0.418301 | 0.383877 | Failed |
| regression: unnormalised weights | 1.428571 | 1.417323 | Failed |
| regression: early window truncation | 2.1 | 2.76 | Failed |
| control: boundary window reaching day 0 | None | None | Passed |
| control: t out of range | None | None | Passed |
| control: zero history | None | None | Passed |
SHA-256 / 1297612a08df09e7d10c0e2c3de6f6a3bac2027d3ec2130be2cbd1d979e6044d
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(incidence, weights, t, window):
if window < 1 or t - window + 1 < 1 or t >= len(incidence):
return None
num = 0.0
den = 0.0
for k in range(t - window + 1, t):
pressure = 0.0
mass = 0.0
for s in range(1, len(weights) + 1):
if k - s < 0:
break
pressure += weights[s - 1] * incidence[k - s]
mass += weights[s - 1]
if mass > 0:
pressure /= mass
num += incidence[k]
den += pressure
if den <= 0:
return None
return round(num / den, 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)],
[('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('regression: window starting on day 1', ([4, 6, 9, 12], [0.5, 0.5], 2, 2), 1.666667),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: growing outbreak | 2.569659 | 2.515432 | Failed |
| regression: declining outbreak | 0.380952 | 0.383877 | Failed |
| regression: unnormalised weights | 1.473684 | 1.417323 | Failed |
| regression: early window truncation | 2.454545 | 2.76 | Failed |
| control: boundary window reaching day 0 | None | None | Passed |
| control: t out of range | None | None | Passed |
| control: zero history | None | None | Passed |
SHA-256 / 30f5a6f4e8a0541152596d6f8919ab92da4164b9d2aa565fe3370356db1b83a9
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(incidence, weights, t, window):
if window < 1 or t - window + 1 < 1 or t >= len(incidence):
return None
num = 0.0
den = 0.0
for k in range(t - window + 1, t + 1):
pressure = 0.0
mass = 0.0
for s in range(1, len(weights) + 1):
if k - s < 0:
break
pressure += weights[s - 1] * incidence[k - s]
mass += weights[s - 1]
if mass > 0:
pressure /= mass
num += incidence[k]
den += pressure
if den <= 0:
return None
return round(num / den, 6)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)],
[('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('regression: window starting on day 1', ([4, 6, 9, 12], [0.5, 0.5], 2, 2), 1.666667),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: single day window at day 1', ([3, 5, 8], [1.0], 1, 1), 1.666667),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('regression: single day window', ([10, 12, 15, 17, 22, 25], [0.25, 0.5, 0.25], 5, 1), 1.408451),
('regression: long serial interval',
([2, 3, 5, 8, 11, 15, 19, 24, 30, 36], [0.1, 0.15, 0.2, 0.25, 0.3], 9, 4),
2.289916),
('control: flat incidence', ([10, 10, 10, 10, 10, 10], [0.5, 0.3, 0.2], 5, 3), 1.0)],
[('regression: growing outbreak', ([1, 2, 4, 7, 12, 20, 33, 50, 80], [0.2, 0.5, 0.3], 8, 3), 2.515432),
('regression: declining outbreak', ([90, 80, 60, 45, 30, 20, 12, 8], [0.3, 0.4, 0.3], 7, 2), 0.383877),
('regression: unnormalised weights', ([5, 6, 8, 9, 11, 14, 16], [2, 3, 1], 6, 2), 1.417323),
('regression: early window truncation', ([3, 5, 9, 14, 20], [0.1, 0.2, 0.3, 0.4], 3, 2), 2.76),
('control: boundary window reaching day 0', ([4, 6, 9, 12], [0.5, 0.5], 2, 3), None),
('control: t out of range', ([4, 6, 9], [0.5, 0.5], 3, 1), None),
('control: zero history', ([0, 0, 0, 5, 7], [0.6, 0.4], 3, 2), None)]]
for label, args, expected in fixtures[N - 1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: growing outbreak | 2.515432 | 2.515432 | Passed |
| regression: declining outbreak | 0.383877 | 0.383877 | Passed |
| regression: unnormalised weights | 1.417323 | 1.417323 | Passed |
| regression: early window truncation | 2.76 | 2.76 | Passed |
| control: boundary window reaching day 0 | None | None | Passed |
| control: t out of range | None | None | Passed |
| control: zero history | None | None | Passed |
SHA-256 / e0c3b6fa41c9b8ec736f6f7f43104afc822423e3c910a6d2a3932b80a5f15a8f
Verification & scope
Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:47:31.111375+00:00.
Case digest / 8fc4b9674ad7caa1b3a8a72749faf2d2b0036bc86a206c4abb63877b950648e4