FAILURE MAP
← Case archive

FA-65486 / Ecological population dynamics / Open access

Cohort life table statistics: generation time weighting · case 01

Generation time is one year too long.

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

ROOT CAUSE

Ages are counted from one instead of zero.

VERIFIED REPAIR

Restore the generation time weighting rule: `sum(x * l[x] * mx[x] for x in range(n))`.

Unsuccessful approach: Dropping survivorship weights the ages incorrectly.

Case contract

l0=1 and l[x+1]=l[x]*px[x]; R0=sum l[x]*mx[x]; generation time T=sum x*l[x]*mx[x]/R0; r=ln(R0)/T (None if T=0); e0 = sum over x of (l[x]+l[x+1])/2; return [R0, T, r, e0] rounded 6 with [0.0, None, None, e0] when R0=0; None for empty or mismatched schedules.

Why this case matters

Population projections set harvest quotas, conservation status and pest-control timing; a wrong update order, boundary or rate conversion silently changes management advice.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(px, mx):
    n = len(px)
    if n == 0 or len(mx) != n:
        return None
    l = [1.0]
    for x in range(1, n + 1):
        l.append(l[-1] * px[x - 1])
    e0 = round(sum((l[x] + l[x + 1]) / 2 for x in range(n)), 6)
    r0 = sum(l[x] * mx[x] for x in range(n))
    if r0 <= 0:
        return [0.0, None, None, e0]
    gen = sum((x + 1) * l[x] * mx[x] for x in range(n)) / r0
    rate = math.log(r0) / gen if gen > 0 else None
    return [round(r0, 6), round(gen, 6), None if rate is None else round(rate, 6), e0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: songbird[1.026, 2.77193, 0.00926, 1.115][1.026, 1.77193, 0.014486, 1.115]Failed
regression: perennial plant[1.4944, 4.079229, 0.098481, 0.8168][1.4944, 3.079229, 0.130463, 0.8168]Failed
regression: replacement cohort[2.0, 2.0, 0.346574, 1.125][2.0, 1.0, 0.693147, 1.125]Failed
regression: age zero breeding only[1.5, 1.0, 0.405465, 1.05][1.5, 0.0, None, 1.05]Failed
control: sterile cohort[0.0, None, None, 1.805][0.0, None, None, 1.805]Passed
control: mismatched schedulesNoneNonePassed
regression: annual insect[1.5, 2.0, 0.202733, 0.55][1.5, 1.0, 0.405465, 0.55]Failed

SHA-256 / ad5db26808c60d3e41d7f3b86ec4f62828b9b3c7163ea444c53ffb59140c6306

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(px, mx):
    n = len(px)
    if n == 0 or len(mx) != n:
        return None
    l = [1.0]
    for x in range(1, n + 1):
        l.append(l[-1] * px[x - 1])
    e0 = round(sum((l[x] + l[x + 1]) / 2 for x in range(n)), 6)
    r0 = sum(l[x] * mx[x] for x in range(n))
    if r0 <= 0:
        return [0.0, None, None, e0]
    gen = sum(x * mx[x] for x in range(n)) / r0
    rate = math.log(r0) / gen if gen > 0 else None
    return [round(r0, 6), round(gen, 6), None if rate is None else round(rate, 6), e0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: songbird[1.026, 11.208577, 0.00229, 1.115][1.026, 1.77193, 0.014486, 1.115]Failed
regression: perennial plant[1.4944, 44.164882, 0.009096, 0.8168][1.4944, 3.079229, 0.130463, 0.8168]Failed
regression: replacement cohort[2.0, 2.0, 0.346574, 1.125][2.0, 1.0, 0.693147, 1.125]Failed
regression: age zero breeding only[1.5, 0.0, None, 1.05][1.5, 0.0, None, 1.05]Passed
control: sterile cohort[0.0, None, None, 1.805][0.0, None, None, 1.805]Passed
control: mismatched schedulesNoneNonePassed
regression: annual insect[1.5, 20.0, 0.020273, 0.55][1.5, 1.0, 0.405465, 0.55]Failed

SHA-256 / 31b76c0b8bf0a110f024f56ebca0c85c5418e61a3c50218f3e4bef55b9f2cb1c

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(px, mx):
    n = len(px)
    if n == 0 or len(mx) != n:
        return None
    l = [1.0]
    for x in range(1, n + 1):
        l.append(l[-1] * px[x - 1])
    e0 = round(sum((l[x] + l[x + 1]) / 2 for x in range(n)), 6)
    r0 = sum(l[x] * mx[x] for x in range(n))
    if r0 <= 0:
        return [0.0, None, None, e0]
    gen = sum(x * l[x] * mx[x] for x in range(n)) / r0
    rate = math.log(r0) / gen if gen > 0 else None
    return [round(r0, 6), round(gen, 6), None if rate is None else round(rate, 6), e0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('regression: age zero breeding only', ([0.5, 0.2], [1.5, 0.0]), [1.5, 0.0, None, 1.05]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])],
 [('regression: songbird', ([0.3, 0.6, 0.6, 0.5], [0.0, 1.5, 2.0, 2.0]), [1.026, 1.77193, 0.014486, 1.115]),
  ('regression: perennial plant',
   ([0.1, 0.8, 0.9, 0.9, 0.0], [0.0, 0.0, 5.0, 8.0, 8.0]),
   [1.4944, 3.079229, 0.130463, 0.8168]),
  ('regression: replacement cohort', ([0.5, 0.5], [0.0, 4.0]), [2.0, 1.0, 0.693147, 1.125]),
  ('control: sterile cohort', ([0.9, 0.9], [0.0, 0.0]), [0.0, None, None, 1.805]),
  ('control: mismatched schedules', ([0.5], [0.0, 1.0]), None),
  ('regression: annual insect', ([0.05, 0.0], [0.0, 30.0]), [1.5, 1.0, 0.405465, 0.55]),
  ('regression: long-lived',
   ([0.95, 0.95, 0.95, 0.95, 0.95, 0.9], [0.0, 0.0, 0.2, 0.4, 0.4, 0.4]),
   [1.158765, 3.659605, 0.040265, 5.146364])]]
for label, args, expected in fixtures[N - 1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: songbird[1.026, 1.77193, 0.014486, 1.115][1.026, 1.77193, 0.014486, 1.115]Passed
regression: perennial plant[1.4944, 3.079229, 0.130463, 0.8168][1.4944, 3.079229, 0.130463, 0.8168]Passed
regression: replacement cohort[2.0, 1.0, 0.693147, 1.125][2.0, 1.0, 0.693147, 1.125]Passed
regression: age zero breeding only[1.5, 0.0, None, 1.05][1.5, 0.0, None, 1.05]Passed
control: sterile cohort[0.0, None, None, 1.805][0.0, None, None, 1.805]Passed
control: mismatched schedulesNoneNonePassed
regression: annual insect[1.5, 1.0, 0.405465, 0.55][1.5, 1.0, 0.405465, 0.55]Passed

SHA-256 / fcb1ffe1d1b6c83c92eee3b6193450587ec61aa4618acc7d03f54b44b3d6955f

Verification & scope

Deterministic bounded teaching model with a stipulated contract; not a validated scientific or public-health modelling library. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:34.530199+00:00.

Case digest / 306a997835203fb42dca2bffe40d5e6b95b12ce9c4ddd956cdba804f332daad2