FAILURE MAP
← Case archive

FA-65161 / Epidemic compartment models / Open access

Epidemic growth rate, doubling time and R: stage split · case 01

R is overstated whenever there is a latent period.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The infectious stage duration is not reduced by the latent stage.

THE FAILURE

The infectious stage duration is not reduced by the latent stage.

Unsuccessful approach: Halving the remaining time splits the generation interval inconsistently.

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
    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 = [[('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: 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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
  ('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),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: 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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: 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 fixtureActualExpectedOutcome
regression: noisy growth[0.372323, 1.8617, 4.992511][0.372323, 1.8617, 3.693365]Failed
regression: with reporting gap zero[0.437065, 1.5859, 8.372041][0.437065, 1.5859, 5.341617]Failed
regression: declining[-0.246645, None, 0.009449][-0.246645, None, 0.217822]Failed
control: flat[0.0, None, 1.0][0.0, None, 1.0]Passed
control: too few positivesNoneNonePassed
regression: exact doubling per day[0.693147, 1.0, 6.281201][0.693147, 1.0, 4.160461]Failed
regression: leading zeros[0.796555, 0.8702, 28.575686][0.796555, 0.8702, 14.037592]Failed

SHA-256 / b9161fe49795a14db83a026d8b0db8b5110674c31d56b1db3cf9dee535514d17

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) / r, 4) if r > 0 else None
    tl = latent_fraction * generation_mean
    ti = (generation_mean - tl) / 2
    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 = [[('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: 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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: with reporting gap zero', ([2, 4, 0, 9, 13, 0, 30], 6.0, 0.5), [0.437065, 1.5859, 5.341617]),
  ('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),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: two points', ([5, 9], 4.5, 0.25), [0.587787, 1.1792, 4.956834])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('regression: 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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592])],
 [('regression: noisy growth', ([3, 5, 6, 10, 14, 19, 30], 5.0, 0.4), [0.372323, 1.8617, 3.693365]),
  ('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),
  ('regression: exact doubling per day', ([1, 2, 4, 8, 16], 3.0, 0.5), [0.693147, 1.0, 4.160461]),
  ('regression: leading zeros', ([0, 0, 1, 3, 5, 12], 7.0, 0.6), [0.796555, 0.8702, 14.037592]),
  ('regression: no latency', ([10, 13, 17, 22, 28], 5.0, 0.0), [0.258533, 2.6811, 2.292666]),
  ('regression: 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 fixtureActualExpectedOutcome
regression: noisy growth[0.372323, 1.8617, 2.719006][0.372323, 1.8617, 3.693365]Failed
regression: with reporting gap zero[0.437065, 1.5859, 3.826406][0.437065, 1.5859, 5.341617]Failed
regression: declining[-0.246645, None, 0.460924][-0.246645, None, 0.217822]Failed
control: flat[0.0, None, 1.0][0.0, None, 1.0]Passed
control: too few positivesNoneNonePassed
regression: exact doubling per day[0.693147, 1.0, 3.100091][0.693147, 1.0, 4.160461]Failed
regression: leading zeros[0.796555, 0.8702, 9.191561][0.796555, 0.8702, 14.037592]Failed

SHA-256 / f0e2735d3ba71099942a8c5998250544ca121b430760b78861a9ac2fdf654903

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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.409294+00:00.

Case digest / ed9438970a50a134845fb07d7f5d677485374f4b8a1d322ee5cb31abbf444263