prompt:
A stock that starts at equilibrium is reported as converging in year 1.

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


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

prompt:
Predator growth responds to prey that were already updated in the same step.

dx = alpha*x - beta*x*y, dy = delta*x*y - gamma*y evaluated from the same start-of-step state; Euler update with each population floored at 0; return [path of [x,y] rounded 4 including start, coexistence equilibrium [gamma/delta, alpha/beta] rounded 4 or None when beta or delta is not positive].

split: open-access


prompt:
Predators gain one individual per prey eaten regardless of conversion efficiency.

dx = alpha*x - beta*x*y, dy = delta*x*y - gamma*y evaluated from the same start-of-step state; Euler update with each population floored at 0; return [path of [x,y] rounded 4 including start, coexistence equilibrium [gamma/delta, alpha/beta] rounded 4 or None when beta or delta is not positive].

split: open-access


prompt:
Predator mortality is a constant loss that drives small populations negative.

dx = alpha*x - beta*x*y, dy = delta*x*y - gamma*y evaluated from the same start-of-step state; Euler update with each population floored at 0; return [path of [x,y] rounded 4 including start, coexistence equilibrium [gamma/delta, alpha/beta] rounded 4 or None when beta or delta is not positive].

split: open-access


prompt:
The reported coexistence point has prey and predator swapped.

dx = alpha*x - beta*x*y, dy = delta*x*y - gamma*y evaluated from the same start-of-step state; Euler update with each population floored at 0; return [path of [x,y] rounded 4 including start, coexistence equilibrium [gamma/delta, alpha/beta] rounded 4 or None when beta or delta is not positive].

split: open-access


prompt:
Large steps drive prey negative, which then feeds predators negatively.

dx = alpha*x - beta*x*y, dy = delta*x*y - gamma*y evaluated from the same start-of-step state; Euler update with each population floored at 0; return [path of [x,y] rounded 4 including start, coexistence equilibrium [gamma/delta, alpha/beta] rounded 4 or None when beta or delta is not positive].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])]]
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(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else a * prey / (1 + h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('regression: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])]]
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:
Filter feeders are capped at the handling time instead of the maximum intake rate.

Per-predator intake f: type 1 = a*N capped at 1/h (uncapped when h==0), type 2 = aN/(1+ahN), type 3 = aN^2/(1+ahN^2); eaten = min(f*predators*duration, N); return [f rounded 6, eaten rounded 4]; None for negative parameters or unknown kind.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + a * h)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('regression: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('control: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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:
Intake saturates at the wrong prey density.

Per-predator intake f: type 1 = a*N capped at 1/h (uncapped when h==0), type 2 = aN/(1+ahN), type 3 = aN^2/(1+ahN^2); eaten = min(f*predators*duration, N); return [f rounded 6, eaten rounded 4]; None for negative parameters or unknown kind.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752])],
 [('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('control: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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:
Type III intake rises without bound instead of saturating.

Per-predator intake f: type 1 = a*N capped at 1/h (uncapped when h==0), type 2 = aN/(1+ahN), type 3 = aN^2/(1+ahN^2); eaten = min(f*predators*duration, N); return [f rounded 6, eaten rounded 4]; None for negative parameters or unknown kind.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = f * predators * duration
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])],
 [('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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(kind, a, h, prey, predators, duration):
    if a < 0 or h < 0 or prey < 0:
        return None
    if kind == 1:
        f = a * prey if h == 0 else min(a * prey, 1 / h)
    elif kind == 2:
        f = a * prey / (1 + a * h * prey)
    elif kind == 3:
        f = a * prey ** 2 / (1 + a * h * prey ** 2)
    else:
        return None
    eaten = min(f * predators * duration, prey * predators)
    return [round(f, 6), round(eaten, 4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])],
 [('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0])],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: unknown kind', (4, 0.1, 0.1, 10, 1, 1), None),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 saturated filter feeder', (1, 0.5, 0.25, 20, 2, 1), [4.0, 8.0]),
  ('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10]),
  ('control: no prey', (2, 0.5, 0.5, 0, 2, 1), [0.0, 0.0]),
  ('control: invalid negative handling', (2, 0.5, -0.1, 10, 1, 1), None)],
 [('control: type 1 unsaturated', (1, 0.1, 0.5, 10, 1, 2), [1.0, 2.0]),
  ('control: type 1 no handling', (1, 0.3, 0.0, 40, 1, 1), [12.0, 12.0]),
  ('control: type 2 wolves on moose', (2, 0.8, 0.5, 30, 3, 2), [1.846154, 11.0769]),
  ('control: type 2 low density', (2, 0.2, 0.1, 3, 1, 1), [0.566038, 0.566]),
  ('regression: type 3 prey switching', (3, 0.05, 0.2, 12, 2, 3), [2.95082, 12]),
  ('control: type 3 high density', (3, 0.1, 0.4, 50, 1, 1), [2.475248, 2.4752]),
  ('regression: depletion cap', (2, 2.0, 0.05, 10, 20, 5), [10.0, 10])]]
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:
More prey are eaten than exist.

Per-predator intake f: type 1 = a*N capped at 1/h (uncapped when h==0), type 2 = aN/(1+ahN), type 3 = aN^2/(1+ahN^2); eaten = min(f*predators*duration, N); return [f rounded 6, eaten rounded 4]; None for negative parameters or unknown kind.

split: open-access


prompt:
Births stay fixed at the initial level every year.

Births new[0] = sum f_i*n_i; survivors new[i+1] = s_i*n_i; with plus_group the last class also retains s_last*n_last; ratio is total(t)/total(t-1) of the final year (None if the previous total was 0 or no years); return [final vector rounded 4, total rounded 4, ratio rounded 6].

split: open-access


prompt:
Classes age without moving: survivors come from the destination class.

Births new[0] = sum f_i*n_i; survivors new[i+1] = s_i*n_i; with plus_group the last class also retains s_last*n_last; ratio is total(t)/total(t-1) of the final year (None if the previous total was 0 or no years); return [final vector rounded 4, total rounded 4, ratio rounded 6].

split: open-access


prompt:
The plus group loses all incoming recruits from the previous class.

Births new[0] = sum f_i*n_i; survivors new[i+1] = s_i*n_i; with plus_group the last class also retains s_last*n_last; ratio is total(t)/total(t-1) of the final year (None if the previous total was 0 or no years); return [final vector rounded 4, total rounded 4, ratio rounded 6].

split: open-access


prompt:
The reported annual growth ratio is really growth since the initial year, or a stale total.

Births new[0] = sum f_i*n_i; survivors new[i+1] = s_i*n_i; with plus_group the last class also retains s_last*n_last; ratio is total(t)/total(t-1) of the final year (None if the previous total was 0 or no years); return [final vector rounded 4, total rounded 4, ratio rounded 6].

split: open-access


prompt:
An already-extinct population reports a growth ratio.

Births new[0] = sum f_i*n_i; survivors new[i+1] = s_i*n_i; with plus_group the last class also retains s_last*n_last; ratio is total(t)/total(t-1) of the final year (None if the previous total was 0 or no years); return [final vector rounded 4, total rounded 4, ratio rounded 6].

split: open-access


prompt:
Survivorship rises again after a bad year.

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.

split: open-access


prompt:
R0 ignores mortality before breeding.

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.

split: open-access


prompt:
Generation time is one year too long.

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.

split: open-access


prompt:
Intrinsic growth is overstated for strongly growing cohorts.

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.

split: open-access


prompt:
Life expectancy ignores that deaths occur during the interval.

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.

split: open-access


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

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

prompt:
Chapman estimates are one animal too high.

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].

split: open-access


broken_source:
"""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 * caught / (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)

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

prompt:
Chapman estimates are biased low, especially with few recaptures.

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].

split: open-access


broken_source:
"""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) * (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]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8])],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('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]),
  ('control: 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)

source:
"""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) ** 3
    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]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('control: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8])],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('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]),
  ('control: 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)

prompt:
Confidence intervals are far too wide.

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].

split: open-access


broken_source:
"""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 > marked:
        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 = [[('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None)],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: 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)

source:
"""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 > max(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 = [[('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None)],
 [('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('control: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: all recaptured', (30, 30, 30, 'chapman'), [30.0, 0.0]),
  ('regression: recaptures exceed catch', (80, 10, 12, 'chapman'), None),
  ('regression: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: 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)

prompt:
Impossible samples with more recaptures than animals caught are estimated.

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].

split: open-access


broken_source:
"""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:
            recaptured = 1
        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 = [[('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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)],
 [('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: 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)

source:
"""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 [0.0, 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 = [[('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: recaptures exceed marked', (10, 80, 12, 'lp'), None),
  ('control: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: butterflies', (200, 150, 45, 'chapman'), [658.8, 4966.84]),
  ('control: negative recapture', (20, 20, -1, 'lp'), None)],
 [('control: trout chapman', (120, 100, 20, 'chapman'), [580.95, 10077.1]),
  ('control: trout petersen', (120, 100, 20, 'lp'), [600.0, None]),
  ('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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)],
 [('control: zero recaptures chapman', (50, 40, 0, 'chapman'), [2090.0, 2091000.0]),
  ('regression: zero recaptures petersen', (50, 40, 0, 'lp'), [None, None]),
  ('control: 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: small sample', (15, 12, 3, 'chapman'), [51.0, 280.8]),
  ('control: 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)

prompt:
A survey with no recaptures reports a finite abundance.

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].

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 * a12 - k2
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a12 * k2) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if c1 < 0 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])]]
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(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 - k2 * a21
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a12 * k2) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if c1 < 0 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])]]
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:
Outcomes flip when competition coefficients are asymmetric.

c1=K1*a21-K2, c2=K2*a12-K1; any zero -> neutral; c1>0,c2<0 species1 wins at [K1,0]; c1<0,c2>0 species2 at [0,K2]; otherwise interior N1=(K1-a12K2)/(1-a12a21), N2=(K2-a21K1)/(1-a12a21), coexist if both negative, founder if both positive; None for non-positive K or negative coefficients (zero allowed).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 * a21 - k2
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a12 * k2) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if c1 > 0 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None)]]
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(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 * a21 - k2
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a12 * k2) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if a12 < 1 and a21 < 1 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('regression: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None)]]
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:
Stable coexistence and founder control are swapped.

c1=K1*a21-K2, c2=K2*a12-K1; any zero -> neutral; c1>0,c2<0 species1 wins at [K1,0]; c1<0,c2>0 species2 at [0,K2]; otherwise interior N1=(K1-a12K2)/(1-a12a21), N2=(K2-a21K1)/(1-a12a21), coexist if both negative, founder if both positive; None for non-positive K or negative coefficients (zero allowed).

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 * a21 - k2
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a21 * k2) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if c1 < 0 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None)]]
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(k1, k2, a12, a21):
    if min(k1, k2) <= 0 or min(a12, a21) < 0:
        return None
    c1 = k1 * a21 - k2
    c2 = k2 * a12 - k1
    if c1 == 0 or c2 == 0:
        return ['neutral', None]
    if c1 > 0 and c2 < 0:
        return ['species1', [float(k1), 0.0]]
    if c1 < 0 and c2 > 0:
        return ['species2', [0.0, float(k2)]]
    den = 1 - a12 * a21
    n1 = (k1 - a12 * k1) / den
    n2 = (k2 - a21 * k1) / den
    kind = 'coexist' if c1 < 0 else 'founder'
    return [kind, [round(n1, 4), round(n2, 4)]]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]])],
 [('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None),
  ('control: invalid capacity', (0, 100, 0.5, 0.5), None),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('regression: weak competition coexist', (100, 80, 0.5, 0.4), ['coexist', [75.0, 50.0]]),
  ('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: near tie', (100, 99.5, 1.0, 1.0), ['species1', [100.0, 0.0]]),
  ('regression: founder asymmetric', (90, 150, 2.0, 2.5), ['founder', [52.5, 18.75]])],
 [('control: strong asymmetric species1', (100, 60, 0.5, 1.2), ['species1', [100.0, 0.0]]),
  ('control: species2 wins', (50, 120, 1.5, 0.3), ['species2', [0.0, 120.0]]),
  ('regression: founder control', (100, 100, 1.5, 1.6), ['founder', [35.7143, 42.8571]]),
  ('control: neutral tie', (100, 50, 1.0, 0.5), ['neutral', None]),
  ('control: no competition', (70, 40, 0.0, 0.0), ['coexist', [70.0, 40.0]]),
  ('regression: coexist with one strong coefficient', (200, 60, 1.5, 0.2), ['coexist', [157.1429, 28.5714]]),
  ('control: invalid negative coefficient', (100, 100, -0.1, 0.5), None)]]
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 coexistence abundance of species 1 is wrong whenever a12 differs from a21.

c1=K1*a21-K2, c2=K2*a12-K1; any zero -> neutral; c1>0,c2<0 species1 wins at [K1,0]; c1<0,c2>0 species2 at [0,K2]; otherwise interior N1=(K1-a12K2)/(1-a12a21), N2=(K2-a21K1)/(1-a12a21), coexist if both negative, founder if both positive; None for non-positive K or negative coefficients (zero allowed).

split: open-access