FA-316 / Numerical aggregation / Open access
A weighted total is divided by the number of records · case 01
Changing the scale of weights changes the result, or unequal-weight observations are treated as equally influential.
ROOT CAUSE
The denominator counts records instead of summing the same weights used in the numerator.
VERIFIED REPAIR
Divide the sum of value-times-weight by the total weight using exact rational arithmetic.
Unsuccessful approach: Dropping zero-weight records and taking an ordinary mean ignores the remaining unequal weights.
Case contract
For integer [value, nonnegative weight] pairs, return the exact weighted mean as a reduced Fraction string. Negative weights, no records, or zero total weight return None. Zero-valued observations remain valid.
Why this case matters
Metrics combined across unequal sample counts need a weighted denominator. Scaling all weights should preserve the result; ignoring that invariant produces misleading aggregate summaries.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(samples):
if not samples or any(weight < 0 for value, weight in samples) or not sum(weight for value, weight in samples):
return None
return str(Fraction(sum(value * weight for value, weight in samples), len(samples)))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights including zero value', solve([[0, 1], [6 * N, 2]]), str(4 * N))
check('uniform weight scaling changes nothing', solve([[0, 7], [6 * N, 14]]), str(4 * N))
check('equal weights', solve([[2 * N, 3], [4 * N, 3]]), str(3 * N))
check('zero weight contributes nothing', solve([[100 * N, 0], [2 * N, 3]]), str(2 * N))
check('fractional result remains exact', solve([[N, 1], [N + 1, 2]]), f'{3 * N + 2}/3')
check('negative observed values allowed', solve([[-6 * N, 2], [0, 1]]), str(-4 * N))
check('zero total weight', solve([[N, 0]]), None)
check('negative weight rejected', solve([[N, -1], [N, 2]]), None)
check('no observations', solve([]), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal weights including zero value | 6 | 4 | Failed |
| uniform weight scaling changes nothing | 42 | 4 | Failed |
| equal weights | 9 | 3 | Failed |
| zero weight contributes nothing | 3 | 2 | Failed |
| fractional result remains exact | 5/2 | 5/3 | Failed |
| negative observed values allowed | -6 | -4 | Failed |
| zero total weight | None | None | Passed |
| negative weight rejected | None | None | Passed |
| no observations | None | None | Passed |
SHA-256 / d1beed9a38b3fa4b90ed1b231faa409cbc8d67b91ff35596fcfde8635fea616f
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(samples):
if not samples or any(weight < 0 for value, weight in samples):
return None
values = [value for value, weight in samples if weight > 0]
return str(Fraction(sum(values), len(values))) if values else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights including zero value', solve([[0, 1], [6 * N, 2]]), str(4 * N))
check('uniform weight scaling changes nothing', solve([[0, 7], [6 * N, 14]]), str(4 * N))
check('equal weights', solve([[2 * N, 3], [4 * N, 3]]), str(3 * N))
check('zero weight contributes nothing', solve([[100 * N, 0], [2 * N, 3]]), str(2 * N))
check('fractional result remains exact', solve([[N, 1], [N + 1, 2]]), f'{3 * N + 2}/3')
check('negative observed values allowed', solve([[-6 * N, 2], [0, 1]]), str(-4 * N))
check('zero total weight', solve([[N, 0]]), None)
check('negative weight rejected', solve([[N, -1], [N, 2]]), None)
check('no observations', solve([]), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal weights including zero value | 3 | 4 | Failed |
| uniform weight scaling changes nothing | 3 | 4 | Failed |
| equal weights | 3 | 3 | Passed |
| zero weight contributes nothing | 2 | 2 | Passed |
| fractional result remains exact | 3/2 | 5/3 | Failed |
| negative observed values allowed | -3 | -4 | Failed |
| zero total weight | None | None | Passed |
| negative weight rejected | None | None | Passed |
| no observations | None | None | Passed |
SHA-256 / 618ca2de3e1e844b42f908cdba277bddd835c97f60bd44c127c2a758cfe2e4ff
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(samples):
if not samples or any(weight < 0 for value, weight in samples):
return None
total = sum(weight for value, weight in samples)
return str(Fraction(sum(value * weight for value, weight in samples), total)) if total else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights including zero value', solve([[0, 1], [6 * N, 2]]), str(4 * N))
check('uniform weight scaling changes nothing', solve([[0, 7], [6 * N, 14]]), str(4 * N))
check('equal weights', solve([[2 * N, 3], [4 * N, 3]]), str(3 * N))
check('zero weight contributes nothing', solve([[100 * N, 0], [2 * N, 3]]), str(2 * N))
check('fractional result remains exact', solve([[N, 1], [N + 1, 2]]), f'{3 * N + 2}/3')
check('negative observed values allowed', solve([[-6 * N, 2], [0, 1]]), str(-4 * N))
check('zero total weight', solve([[N, 0]]), None)
check('negative weight rejected', solve([[N, -1], [N, 2]]), None)
check('no observations', solve([]), None)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal weights including zero value | 4 | 4 | Passed |
| uniform weight scaling changes nothing | 4 | 4 | Passed |
| equal weights | 3 | 3 | Passed |
| zero weight contributes nothing | 2 | 2 | Passed |
| fractional result remains exact | 5/3 | 5/3 | Passed |
| negative observed values allowed | -4 | -4 | Passed |
| zero total weight | None | None | Passed |
| negative weight rejected | None | None | Passed |
| no observations | None | None | Passed |
SHA-256 / 7fdb597e77d4b1b4a20450d9db5f568508f3e264f607550ebba0839a3b759563
Verification & scope
This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:36:52.070577+00:00.
Case digest / 8e6e965608df55b501194a157b14d5ab0ea4921fd345c76af98dde9273b48102