FAILURE MAP
← Case archive

FA-65501 / Ecological population dynamics / Open access

Two-sample mark-recapture abundance: chapman offset · case 01

Chapman estimates are one animal too high.

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

ROOT CAUSE

The trailing -1 of the Chapman estimator is omitted.

VERIFIED REPAIR

Restore the chapman offset rule: `/ (recaptured + 1) - 1`.

Unsuccessful approach: Adding one instead of subtracting doubles the bias.

Case contract

Recaptures must be in [0, min(marked, caught)] else None; 'lp' = M*C/R ([None, None] when R=0, no variance); Chapman = (M+1)(C+1)/(R+1)-1 with variance (M+1)(C+1)(M-R)(C-R)/((R+1)^2 (R+2)); return [estimate rounded 2, variance rounded 2 or None].

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(marked, caught, recaptured, method):
    if recaptured < 0 or recaptured > min(marked, caught):
        return None
    if method == 'lp':
        if recaptured == 0:
            return [None, None]
        return [round(marked * caught / recaptured, 2), None]
    est = (marked + 1) * (caught + 1) / (recaptured + 1)
    var = (marked + 1) * (caught + 1) * (marked - recaptured) * (caught - recaptured) / ((recaptured + 1) ** 2 * (recaptured + 2))
    return [round(est, 2), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None)],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84])]]
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: trout chapman[581.95, 10077.1][580.95, 10077.1]Failed
control: trout petersen[600.0, None][600.0, None]Passed
regression: zero recaptures chapman[2091.0, 2091000.0][2090.0, 2091000.0]Failed
control: zero recaptures petersen[None, None][None, None]Passed
regression: all recaptured[31.0, 0.0][30.0, 0.0]Failed
control: recaptures exceed catchNoneNonePassed
control: recaptures exceed markedNoneNonePassed

SHA-256 / 9f1c343574f2e23405a1e66d52c140d2081de5a61e2c2442f0f2edcd868185c0

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(marked, caught, recaptured, method):
    if recaptured < 0 or recaptured > min(marked, caught):
        return None
    if method == 'lp':
        if recaptured == 0:
            return [None, None]
        return [round(marked * caught / recaptured, 2), None]
    est = (marked + 1) * (caught + 1) / (recaptured + 1) + 1
    var = (marked + 1) * (caught + 1) * (marked - recaptured) * (caught - recaptured) / ((recaptured + 1) ** 2 * (recaptured + 2))
    return [round(est, 2), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None)],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84])]]
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: trout chapman[582.95, 10077.1][580.95, 10077.1]Failed
control: trout petersen[600.0, None][600.0, None]Passed
regression: zero recaptures chapman[2092.0, 2091000.0][2090.0, 2091000.0]Failed
control: zero recaptures petersen[None, None][None, None]Passed
regression: all recaptured[32.0, 0.0][30.0, 0.0]Failed
control: recaptures exceed catchNoneNonePassed
control: recaptures exceed markedNoneNonePassed

SHA-256 / af1e17779b763e1ee87f747aacec31ab3778c401f584e17b375d5409b3075302

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(marked, caught, recaptured, method):
    if recaptured < 0 or recaptured > min(marked, caught):
        return None
    if method == 'lp':
        if recaptured == 0:
            return [None, None]
        return [round(marked * caught / recaptured, 2), None]
    est = (marked + 1) * (caught + 1) / (recaptured + 1) - 1
    var = (marked + 1) * (caught + 1) * (marked - recaptured) * (caught - recaptured) / ((recaptured + 1) ** 2 * (recaptured + 2))
    return [round(est, 2), round(var, 2)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None)],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('regression: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('regression: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('regression: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84])]]
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: trout chapman[580.95, 10077.1][580.95, 10077.1]Passed
control: trout petersen[600.0, None][600.0, None]Passed
regression: zero recaptures chapman[2090.0, 2091000.0][2090.0, 2091000.0]Passed
control: zero recaptures petersen[None, None][None, None]Passed
regression: all recaptured[30.0, 0.0][30.0, 0.0]Passed
control: recaptures exceed catchNoneNonePassed
control: recaptures exceed markedNoneNonePassed

SHA-256 / eb949029b4e8b92cf268ff70ea80f30fca023ba48366f42df708644d1fa8174c

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

Case digest / 18d7d2079fa08651adbfa6e2e01cdcddcbd7176944deba48a32df7ace24020e4