FA-6191 / Statistics / Open access
Upper median order statistic · case 01
The lower middle position violates the upper-median convention.
ROOT CAUSE
The lower middle position violates the upper-median convention.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sorted(values)[len(values)//2] if values else None
Unsuccessful approach: The interpolated median is not the required upper order statistic.
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. Upper median order statistic. Exact operational definition: sorted(values)[len(values)//2] 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 sorted(values)[(len(values)-1)//2] 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, 8, 9],)', solve(*([1, 2, 8, 9],)), 8)
check('fixture 2: ([9, 1, 2],)', solve(*([9, 1, 2],)), 2)
check('fixture 3: ([4],)', solve(*([4],)), 4)
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, 8, 9],) | 2 | 8 | Failed |
| fixture 2: ([9, 1, 2],) | 2 | 2 | Passed |
| fixture 3: ([4],) | 4 | 4 | Passed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / 127d044854b91a360b4e6ed9745ba57a5b6396da7127015e3e2f780898df0c29
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 statistics.median(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, 8, 9],)', solve(*([1, 2, 8, 9],)), 8)
check('fixture 2: ([9, 1, 2],)', solve(*([9, 1, 2],)), 2)
check('fixture 3: ([4],)', solve(*([4],)), 4)
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, 8, 9],) | 5.0 | 8 | Failed |
| fixture 2: ([9, 1, 2],) | 2 | 2 | Passed |
| fixture 3: ([4],) | 4 | 4 | Passed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / 8ea88ac113278f578cf03b25532896ad26489556c0c6eaf22ac845ec9052d931
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 sorted(values)[len(values)//2] 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, 8, 9],)', solve(*([1, 2, 8, 9],)), 8)
check('fixture 2: ([9, 1, 2],)', solve(*([9, 1, 2],)), 2)
check('fixture 3: ([4],)', solve(*([4],)), 4)
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, 8, 9],) | 8 | 8 | Passed |
| fixture 2: ([9, 1, 2],) | 2 | 2 | Passed |
| fixture 3: ([4],) | 4 | 4 | Passed |
| fixture 4: ([],) | None | None | Passed |
SHA-256 / 9297e7e17ca582146d9874b52e716e7da9df667870d6039aa099675143acff80
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.694084+00:00.
Case digest / c96a89b4df0e60281db3622feb3b8eb341ad55d2a147a8e7e9c0feba97332aa8