FA-65151 / Epidemic compartment models / Open access
Epidemic growth rate, doubling time and R: declining doubling time · case 01
Declining epidemics report a negative doubling time.
ROOT CAUSE
Doubling time is computed for any non-zero growth rate.
VERIFIED REPAIR
Restore the declining doubling time rule: `if r > 0 else None`.
Unsuccessful approach: Taking the absolute rate reports a halving time as a doubling time.
Case contract
r is the least-squares slope of ln(count) against day index over days with positive counts (original day indices kept); doubling time ln2/r only when r>0 else None; latent time Tl=latent_fraction*Tg, infectious time Ti=Tg-Tl, R=(1+r*Tl)*(1+r*Ti); return [r rounded 6, doubling rounded 4, R rounded 6]; None with fewer than two positive days.
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(counts, generation_mean, latent_fraction):
pts = [(d, math.log(c)) for d, c in enumerate(counts) if c > 0]
if len(pts) < 2:
return None
n = len(pts)
mx = sum(d for d, _ in pts) / n
my = sum(y for _, y in pts) / n
sxx = sum((d - mx) ** 2 for d, _ in pts)
sxy = sum((d - mx) * (y - my) for d, y in pts)
r = sxy / sxx
doubling = round(math.log(2) / r, 4) if r != 0 else None
tl = latent_fraction * generation_mean
ti = generation_mean - tl
rep = (1 + r * tl) * (1 + r * ti)
return [round(r, 6), doubling, round(rep, 6)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])]]
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 |
|---|---|---|---|
| control: noisy growth | [0.372323, 1.8617, 3.693365] | [0.372323, 1.8617, 3.693365] | Passed |
| control: with reporting gap zero | [0.437065, 1.5859, 5.341617] | [0.437065, 1.5859, 5.341617] | Passed |
| regression: declining | [-0.246645, -2.8103, 0.217822] | [-0.246645, None, 0.217822] | Failed |
| control: flat | [0.0, None, 1.0] | [0.0, None, 1.0] | Passed |
| control: too few positives | None | None | Passed |
| control: exact doubling per day | [0.693147, 1.0, 4.160461] | [0.693147, 1.0, 4.160461] | Passed |
| control: leading zeros | [0.796555, 0.8702, 14.037592] | [0.796555, 0.8702, 14.037592] | Passed |
SHA-256 / ef6fe1874b1b41bd2cd81539f5990b7ef9c5b69e616117c32bdf0dc8ca0ee554
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, generation_mean, latent_fraction):
pts = [(d, math.log(c)) for d, c in enumerate(counts) if c > 0]
if len(pts) < 2:
return None
n = len(pts)
mx = sum(d for d, _ in pts) / n
my = sum(y for _, y in pts) / n
sxx = sum((d - mx) ** 2 for d, _ in pts)
sxy = sum((d - mx) * (y - my) for d, y in pts)
r = sxy / sxx
doubling = round(math.log(2) / abs(r), 4) if r != 0 else None
tl = latent_fraction * generation_mean
ti = generation_mean - tl
rep = (1 + r * tl) * (1 + r * ti)
return [round(r, 6), doubling, round(rep, 6)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])]]
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 |
|---|---|---|---|
| control: noisy growth | [0.372323, 1.8617, 3.693365] | [0.372323, 1.8617, 3.693365] | Passed |
| control: with reporting gap zero | [0.437065, 1.5859, 5.341617] | [0.437065, 1.5859, 5.341617] | Passed |
| regression: declining | [-0.246645, 2.8103, 0.217822] | [-0.246645, None, 0.217822] | Failed |
| control: flat | [0.0, None, 1.0] | [0.0, None, 1.0] | Passed |
| control: too few positives | None | None | Passed |
| control: exact doubling per day | [0.693147, 1.0, 4.160461] | [0.693147, 1.0, 4.160461] | Passed |
| control: leading zeros | [0.796555, 0.8702, 14.037592] | [0.796555, 0.8702, 14.037592] | Passed |
SHA-256 / 55996c876f888d38761321c63d7d9ac5d05569dff2bfdd48aa77c1fc7e6196ab
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(counts, generation_mean, latent_fraction):
pts = [(d, math.log(c)) for d, c in enumerate(counts) if c > 0]
if len(pts) < 2:
return None
n = len(pts)
mx = sum(d for d, _ in pts) / n
my = sum(y for _, y in pts) / n
sxx = sum((d - mx) ** 2 for d, _ in pts)
sxy = sum((d - mx) * (y - my) for d, y in pts)
r = sxy / sxx
doubling = round(math.log(2) / r, 4) if r > 0 else None
tl = latent_fraction * generation_mean
ti = generation_mean - tl
rep = (1 + r * tl) * (1 + r * ti)
return [round(r, 6), doubling, round(rep, 6)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
[('control: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
('control: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
[('regression: declining', ([50, 41, 30, 26, 18, 15], 4.0, 0.3), [-0.246645, None, 0.217822]),
('control: flat', ([7, 7, 7, 7], 5.0, 0.5), [0.0, None, 1.0]),
('control: too few positives', ([0, 0, 4, 0], 5.0, 0.5), None),
('control: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
('control: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
('control: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
('control: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])]]
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 |
|---|---|---|---|
| control: noisy growth | [0.372323, 1.8617, 3.693365] | [0.372323, 1.8617, 3.693365] | Passed |
| control: with reporting gap zero | [0.437065, 1.5859, 5.341617] | [0.437065, 1.5859, 5.341617] | Passed |
| regression: declining | [-0.246645, None, 0.217822] | [-0.246645, None, 0.217822] | Passed |
| control: flat | [0.0, None, 1.0] | [0.0, None, 1.0] | Passed |
| control: too few positives | None | None | Passed |
| control: exact doubling per day | [0.693147, 1.0, 4.160461] | [0.693147, 1.0, 4.160461] | Passed |
| control: leading zeros | [0.796555, 0.8702, 14.037592] | [0.796555, 0.8702, 14.037592] | Passed |
SHA-256 / db2fcb409e26853cc4e7a9e35c3de481462552f72ead5cf63c2ea73a3f4c236c
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.361779+00:00.
Case digest / 283b5b9c2c8049065f2aa6876155011b032a964dfaa9261972b466d283322d3d