broken_source:
"""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 = (pts[-1][1] - pts[0][1]) / (n - 1)
    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 = [[('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),
  ('control: 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),
  ('control: 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]),
  ('control: 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]),
  ('control: 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),
  ('control: 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),
  ('control: 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]),
  ('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)

source:
"""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 = (pts[-1][1] - pts[0][1]) / (pts[-1][0] - pts[0][0])
    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 = [[('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),
  ('control: 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),
  ('control: 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]),
  ('control: 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]),
  ('control: 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),
  ('control: 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),
  ('control: 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]),
  ('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)

prompt:
Growth rate depends only on the first and last counts and on how many days were positive.

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.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Declining epidemics report a negative doubling time.

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.

split: open-access


broken_source:
"""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.log10(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 = [[('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)

source:
"""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.log2(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 = [[('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)

prompt:
Growth rates are scaled by a constant factor and R is understated.

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.

split: open-access


broken_source:
"""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)

source:
"""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)

prompt:
R is overstated whenever there is a latent period.

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.

split: open-access


broken_source:
"""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 * generation_mean
    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)

source:
"""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 = math.exp(r * generation_mean)
    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)

prompt:
R ignores the two-stage structure of the generation interval.

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.

split: open-access


prompt:
Isolation does not slow transmission.

Daily Euler SIQR: infectives recover (gamma*I) or are detected (detect*I), both exits scaled down proportionally if they exceed I; isolated Q do not transmit and are released to R at Q/isolation_days; report daily detections, final Q and final R rounded to 3.

split: open-access


prompt:
With aggressive testing prevalence becomes negative.

Daily Euler SIQR: infectives recover (gamma*I) or are detected (detect*I), both exits scaled down proportionally if they exceed I; isolated Q do not transmit and are released to R at Q/isolation_days; report daily detections, final Q and final R rounded to 3.

split: open-access


prompt:
Isolated people pile up and are released only in proportion to new detections.

Daily Euler SIQR: infectives recover (gamma*I) or are detected (detect*I), both exits scaled down proportionally if they exceed I; isolated Q do not transmit and are released to R at Q/isolation_days; report daily detections, final Q and final R rounded to 3.

split: open-access


prompt:
People leaving isolation become susceptible again.

Daily Euler SIQR: infectives recover (gamma*I) or are detected (detect*I), both exits scaled down proportionally if they exceed I; isolated Q do not transmit and are released to R at Q/isolation_days; report daily detections, final Q and final R rounded to 3.

split: open-access


prompt:
Reported daily detections accumulate instead of showing new positives.

Daily Euler SIQR: infectives recover (gamma*I) or are detected (detect*I), both exits scaled down proportionally if they exceed I; isolated Q do not transmit and are released to R at Q/isolation_days; report daily detections, final Q and final R rounded to 3.

split: open-access


prompt:
Admissions precede the infections that cause them.

admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].

split: open-access


prompt:
Each patient occupies a bed one day longer than the length of stay.

admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].

split: open-access


prompt:
Patients admitted today are not counted in today's occupancy.

admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].

split: open-access


prompt:
Fractional admissions round to zero and small waves report empty wards.

admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].

split: open-access


prompt:
Plateaus report their last day as the peak instead of the first.

admissions[t] = hosp_frac*infections[t-delay] (0 before the delay); each admission occupies a bed on days t..t+los-1; return [admissions rounded 4, occupancy rounded 4, earliest peak day].

split: open-access


prompt:
The mean infectious period becomes k times too long.

Infectious period split into k sequential stages each left at rate k*gamma; seeds start in stage 1; all stages transmit; Euler with dt=0.1 (10 substeps/day); return [total I at day ends including day 0 rounded 3, R rounded 3], None for k<1.

split: open-access


prompt:
The last stage never fills and nobody reaches R through it.

Infectious period split into k sequential stages each left at rate k*gamma; seeds start in stage 1; all stages transmit; Euler with dt=0.1 (10 substeps/day); return [total I at day ends including day 0 rounded 3, R rounded 3], None for k<1.

split: open-access


prompt:
Recovered counts rise immediately at stage-1 exit rates.

Infectious period split into k sequential stages each left at rate k*gamma; seeds start in stage 1; all stages transmit; Euler with dt=0.1 (10 substeps/day); return [total I at day ends including day 0 rounded 3, R rounded 3], None for k<1.

split: open-access


prompt:
Seeds recover almost immediately.

Infectious period split into k sequential stages each left at rate k*gamma; seeds start in stage 1; all stages transmit; Euler with dt=0.1 (10 substeps/day); return [total I at day ends including day 0 rounded 3, R rounded 3], None for k<1.

split: open-access


prompt:
Transmission falls sharply after the first stage.

Infectious period split into k sequential stages each left at rate k*gamma; seeds start in stage 1; all stages transmit; Euler with dt=0.1 (10 substeps/day); return [total I at day ends including day 0 rounded 3, R rounded 3], None for k<1.

split: open-access


prompt:
Outcome-known cases include people who fell ill after the observation window.

naive CFR = sum(deaths)/sum(cases); delay_pmf[j] is the probability that death occurs j days after onset (j from 0); known = sum_t sum_j cases[t-j]*pmf[j] over t in the series; adjusted = min(sum(deaths)/known, 1); return [naive rounded 6, adjusted rounded 6 or None when known is 0]; None when there are no cases.

split: open-access


prompt:
Every delay is shifted by one day, understating resolved cases.

naive CFR = sum(deaths)/sum(cases); delay_pmf[j] is the probability that death occurs j days after onset (j from 0); known = sum_t sum_j cases[t-j]*pmf[j] over t in the series; adjusted = min(sum(deaths)/known, 1); return [naive rounded 6, adjusted rounded 6 or None when known is 0]; None when there are no cases.

split: open-access


prompt:
Adjusted CFR can exceed 100% early in a surge.

naive CFR = sum(deaths)/sum(cases); delay_pmf[j] is the probability that death occurs j days after onset (j from 0); known = sum_t sum_j cases[t-j]*pmf[j] over t in the series; adjusted = min(sum(deaths)/known, 1); return [naive rounded 6, adjusted rounded 6 or None when known is 0]; None when there are no cases.

split: open-access


prompt:
With no resolved outcomes the adjusted CFR silently equals the naive one.

naive CFR = sum(deaths)/sum(cases); delay_pmf[j] is the probability that death occurs j days after onset (j from 0); known = sum_t sum_j cases[t-j]*pmf[j] over t in the series; adjusted = min(sum(deaths)/known, 1); return [naive rounded 6, adjusted rounded 6 or None when known is 0]; None when there are no cases.

split: open-access


prompt:
Naive CFR is understated by treating deaths as additional cases.

naive CFR = sum(deaths)/sum(cases); delay_pmf[j] is the probability that death occurs j days after onset (j from 0); known = sum_t sum_j cases[t-j]*pmf[j] over t in the series; adjusted = min(sum(deaths)/known, 1); return [naive rounded 6, adjusted rounded 6 or None when known is 0]; None when there are no cases.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - 1
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('regression: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

prompt:
Households with several index cases have understated attack rates.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 0 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('control: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: two index cases', ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],), [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]])],
 [('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('control: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

prompt:
Households without any index case dilute the attack rate.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(sum(a / b for a, b in by_size.values()) / len(by_size), 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / (den - num), 6) if den > num else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

prompt:
The overall SAR weights each household size equally.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(at_risk, (0, 0))
        by_size[at_risk] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size - 1, (0, 0))
        by_size[size - 1] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items())]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

prompt:
Size strata mix households of different sizes that share an at-risk count.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in by_size.items()]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(households):
    num = 0
    den = 0
    by_size = {}
    for size, index, secondary in households:
        at_risk = size - index
        if index < 1 or at_risk <= 0:
            continue
        if secondary > at_risk:
            continue
        num += secondary
        den += at_risk
        a, b = by_size.get(size, (0, 0))
        by_size[size] = (a + secondary, b + at_risk)
    overall = round(num / den, 6) if den else None
    table = [[k, round(a / b, 6)] for k, (a, b) in sorted(by_size.items(), key=lambda kv: -kv[0])]
    return [overall, table]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('regression: two index cases',
   ([[6, 2, 3], [6, 1, 1], [3, 1, 1]],),
   [0.454545, [[3, 0.5], [6, 0.444444]]]),
  ('regression: no index household', ([[4, 0, 0], [4, 1, 1], [3, 1, 2]],), [0.6, [[3, 1.0], [4, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []])],
 [('regression: mixed households',
   ([[4, 1, 2], [3, 1, 0], [5, 2, 1], [2, 1, 1]],),
   [0.444444, [[2, 1.0], [3, 0.0], [4, 0.666667], [5, 0.333333]]]),
  ('control: single-person household', ([[1, 1, 0], [2, 1, 1]],), [1.0, [[2, 1.0]]]),
  ('regression: data error secondary too high',
   ([[3, 1, 4], [3, 1, 1], [5, 1, 2]],),
   [0.5, [[3, 0.5], [5, 0.5]]]),
  ('control: empty input', ([],), [None, []]),
  ('regression: descending sizes',
   ([[7, 1, 3], [2, 1, 0], [4, 1, 1]],),
   [0.4, [[2, 0.0], [4, 0.333333], [7, 0.5]]]),
  ('control: all index', ([[2, 2, 0], [3, 3, 0]],), [None, []]),
  ('regression: large and small',
   ([[8, 1, 6], [2, 1, 1], [8, 2, 1], [3, 1, 0]],),
   [0.5, [[2, 1.0], [3, 0.0], [8, 0.538462]]])]]
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)

prompt:
The size table follows input order.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


prompt:
Data-entry errors produce household SARs above 100%.

Each household is [size, index_cases, secondary]; skip households without an index case, without members at risk, or with more secondaries than at-risk members; pooled SAR = sum secondary / sum (size-index); per-size table sorted by size ascending; return [pooled rounded 6 or None, table].

split: open-access


prompt:
Force of infection uses stale census sizes as migration reshapes the patches.

Each day: local frequency-dependent SIR in each patch using the current patch size, then every compartment exchanges fraction travel of each patch simultaneously; return [S pair, I pair, R pair] rounded 3.

split: open-access


prompt:
Migration creates or destroys people when flows are applied sequentially.

Each day: local frequency-dependent SIR in each patch using the current patch size, then every compartment exchanges fraction travel of each patch simultaneously; return [S pair, I pair, R pair] rounded 3.

split: open-access


prompt:
The epidemic never reaches an unseeded patch.

Each day: local frequency-dependent SIR in each patch using the current patch size, then every compartment exchanges fraction travel of each patch simultaneously; return [S pair, I pair, R pair] rounded 3.

split: open-access


prompt:
R0 scales linearly rather than quadratically with the biting rate.

R0 = m*a^2*b*c*exp(-mu*n)/(r*mu) with biting rate a, transmission probabilities b and c, mosquito density ratio m, human recovery r, mosquito death rate mu and extrinsic incubation n days; return [R0, sqrt(R0) generational value, survival exp(-mu*n)] rounded 6; None if a, r or mu is not positive or m is negative.

split: open-access


prompt:
Survival through the extrinsic incubation period is almost zero for realistic parameters.

R0 = m*a^2*b*c*exp(-mu*n)/(r*mu) with biting rate a, transmission probabilities b and c, mosquito density ratio m, human recovery r, mosquito death rate mu and extrinsic incubation n days; return [R0, sqrt(R0) generational value, survival exp(-mu*n)] rounded 6; None if a, r or mu is not positive or m is negative.

split: open-access


prompt:
R0 ignores the infectious lifespan of the mosquito.

R0 = m*a^2*b*c*exp(-mu*n)/(r*mu) with biting rate a, transmission probabilities b and c, mosquito density ratio m, human recovery r, mosquito death rate mu and extrinsic incubation n days; return [R0, sqrt(R0) generational value, survival exp(-mu*n)] rounded 6; None if a, r or mu is not positive or m is negative.

split: open-access


prompt:
The per-generation reproduction number halves R0 instead of taking its square root.

R0 = m*a^2*b*c*exp(-mu*n)/(r*mu) with biting rate a, transmission probabilities b and c, mosquito density ratio m, human recovery r, mosquito death rate mu and extrinsic incubation n days; return [R0, sqrt(R0) generational value, survival exp(-mu*n)] rounded 6; None if a, r or mu is not positive or m is negative.

split: open-access


prompt:
Changing mosquito-side competence has no effect on R0.

R0 = m*a^2*b*c*exp(-mu*n)/(r*mu) with biting rate a, transmission probabilities b and c, mosquito density ratio m, human recovery r, mosquito death rate mu and extrinsic incubation n days; return [R0, sqrt(R0) generational value, survival exp(-mu*n)] rounded 6; None if a, r or mu is not positive or m is negative.

split: open-access


prompt:
Stocks never settle at carrying capacity; growth follows the initial density forever.

Each year the quota is removed first; if the stock is then <= 0 the trajectory records 0.0 and stops; otherwise the survivors grow by r*N*(1-N/K); the trajectory starts with the unharvested N0; values rounded to 4; None for K<=0 or negative N0.

split: open-access


prompt:
Small stocks survive quotas that should wipe them out before spawning.

Each year the quota is removed first; if the stock is then <= 0 the trajectory records 0.0 and stops; otherwise the survivors grow by r*N*(1-N/K); the trajectory starts with the unharvested N0; values rounded to 4; None for K<=0 or negative N0.

split: open-access


prompt:
A stock harvested to exactly zero keeps a trajectory of zeros instead of stopping.

Each year the quota is removed first; if the stock is then <= 0 the trajectory records 0.0 and stops; otherwise the survivors grow by r*N*(1-N/K); the trajectory starts with the unharvested N0; values rounded to 4; None for K<=0 or negative N0.

split: open-access


prompt:
Trajectories are one year shorter and lose the starting stock.

Each year the quota is removed first; if the stock is then <= 0 the trajectory records 0.0 and stops; otherwise the survivors grow by r*N*(1-N/K); the trajectory starts with the unharvested N0; values rounded to 4; None for K<=0 or negative N0.

split: open-access


prompt:
The superstable case r=1 is labelled damped oscillation.

Regime by r: r<0 decline, r==0 neutral, 0<r<=1 monotone, 1<r<2 damped, 2<=r<2.526 cycle2, else complex; trajectory N[t+1]=N*exp(r*(1-N/K)) rounded 4; None for K<=0 or N0<0.

split: open-access


prompt:
The first period-doubling at r=2 is reported as a damped approach.

Regime by r: r<0 decline, r==0 neutral, 0<r<=1 monotone, 1<r<2 damped, 2<=r<2.526 cycle2, else complex; trajectory N[t+1]=N*exp(r*(1-N/K)) rounded 4; None for K<=0 or N0<0.

split: open-access


prompt:
Populations above carrying capacity turn negative instead of being pulled down smoothly.

Regime by r: r<0 decline, r==0 neutral, 0<r<=1 monotone, 1<r<2 damped, 2<=r<2.526 cycle2, else complex; trajectory N[t+1]=N*exp(r*(1-N/K)) rounded 4; None for K<=0 or N0<0.

split: open-access


prompt:
A population with zero intrinsic growth is reported as monotone convergence.

Regime by r: r<0 decline, r==0 neutral, 0<r<=1 monotone, 1<r<2 damped, 2<=r<2.526 cycle2, else complex; trajectory N[t+1]=N*exp(r*(1-N/K)) rounded 4; None for K<=0 or N0<0.

split: open-access


prompt:
The stock settles well below the stated carrying capacity.

N[t+1] = r0*N/(1+(r0-1)*N/K); equilibrium K if r0>1 else 0; band = 0.01*K; hit = first year (0 = start) with |N-eq|<=band, else None; return [trajectory rounded 4, equilibrium, hit]; None for invalid inputs.

split: open-access


prompt:
Declining stocks are judged against carrying capacity and never converge.

N[t+1] = r0*N/(1+(r0-1)*N/K); equilibrium K if r0>1 else 0; band = 0.01*K; hit = first year (0 = start) with |N-eq|<=band, else None; return [trajectory rounded 4, equilibrium, hit]; None for invalid inputs.

split: open-access


prompt:
Convergence year is the last year inside the band instead of the first.

N[t+1] = r0*N/(1+(r0-1)*N/K); equilibrium K if r0>1 else 0; band = 0.01*K; hit = first year (0 = start) with |N-eq|<=band, else None; return [trajectory rounded 4, equilibrium, hit]; None for invalid inputs.

split: open-access


prompt:
Convergence is almost never detected for large stocks.

N[t+1] = r0*N/(1+(r0-1)*N/K); equilibrium K if r0>1 else 0; band = 0.01*K; hit = first year (0 = start) with |N-eq|<=band, else None; return [trajectory rounded 4, equilibrium, hit]; None for invalid inputs.

split: open-access