FA-6206 / Statistics / Open access
Median absolute deviation · case 01
Deviation from zero replaces deviation from the sample median.
ROOT CAUSE
Deviation from zero replaces deviation from the sample median.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(statistics.median([abs(Fraction(v)-statistics.median([Fraction(x) for x in values])) for v in values])) if values else None
Unsuccessful approach: Mean absolute deviation changes the robust estimator.
Case contract
Integer finite observations and equal lengths for paired samples. Counts and weights are nonnegative. Rational results use reduced Fraction strings. Empty or undefined statistics return None where shown. Return the median of absolute deviations from the sample median, without consistency scaling. Exact operational definition: str(statistics.median([abs(Fraction(v)-statistics.median([Fraction(x) for x in values])) for v in values])) if values else None
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Statistical estimators results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(values):
return str(statistics.median([abs(Fraction(v)) for v in values])) if values else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 100],)', solve(*([1, 2, 100],)), '1')
check('fixture 2: ([10, 10, 10],)', solve(*([10, 10, 10],)), '0')
check('fixture 3: ([1, 3],)', solve(*([1, 3],)), '1')
check('fixture 4: ([],)', 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 |
|---|---|---|---|
| fixture 1: ([1, 2, 100],) | 2 | 1 | Failed |
| fixture 2: ([10, 10, 10],) | 10 | 0 | Failed |
| fixture 3: ([1, 3],) | 2 | 1 | Failed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / 53e86033c2e8c64cc59112740de978c066b928f0769ed958042a22c04c30930b
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(values):
return str(statistics.mean([abs(Fraction(v)-statistics.median([Fraction(x) for x in values])) for v in values])) if values else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 100],)', solve(*([1, 2, 100],)), '1')
check('fixture 2: ([10, 10, 10],)', solve(*([10, 10, 10],)), '0')
check('fixture 3: ([1, 3],)', solve(*([1, 3],)), '1')
check('fixture 4: ([],)', 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 |
|---|---|---|---|
| fixture 1: ([1, 2, 100],) | 33 | 1 | Failed |
| fixture 2: ([10, 10, 10],) | 0 | 0 | Passed |
| fixture 3: ([1, 3],) | 1 | 1 | Passed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / c5f5652d2e64b4a00d4f07916fe7d34bc07d0819a2b1060b3a2ea957ce9543fb
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(values):
return str(statistics.median([abs(Fraction(v)-statistics.median([Fraction(x) for x in values])) for v in values])) if values else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 100],)', solve(*([1, 2, 100],)), '1')
check('fixture 2: ([10, 10, 10],)', solve(*([10, 10, 10],)), '0')
check('fixture 3: ([1, 3],)', solve(*([1, 3],)), '1')
check('fixture 4: ([],)', 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 |
|---|---|---|---|
| fixture 1: ([1, 2, 100],) | 1 | 1 | Passed |
| fixture 2: ([10, 10, 10],) | 0 | 0 | Passed |
| fixture 3: ([1, 3],) | 1 | 1 | Passed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / c6fd6022b9d86cb9dbda899b98f4e220367fb60c25f13f113445dc31290dea5b
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:37:58.706692+00:00.
Case digest / ae3b50b60b11b9eaf7e6ff003feb1e7229eaa3398378d5fc44701888b9f61bc5