FAILURE MAP
← Case archive

FA-6186 / Statistics / Open access

Lower median order statistic · case 01

The upper middle position violates the lower-median convention.

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

ROOT CAUSE

The upper middle position violates the lower-median convention.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return sorted(values)[(len(values)-1)//2] if values else None

Unsuccessful approach: Averaging middle values produces a value that need not be an observation.

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. Lower median order statistic. Exact operational definition: sorted(values)[(len(values)-1)//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)//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],)), 2)
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 fixtureActualExpectedOutcome
fixture 1: ([1, 2, 8, 9],)82Failed
fixture 2: ([9, 1, 2],)22Passed
fixture 3: ([4],)44Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / 70d54c4005038aa9e5be0dce13bb4cf62d43c8147098faca09e8ebede4ea7994

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],)), 2)
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 fixtureActualExpectedOutcome
fixture 1: ([1, 2, 8, 9],)5.02Failed
fixture 2: ([9, 1, 2],)22Passed
fixture 3: ([4],)44Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / b3cd5d8e04cf33e106c0ff5be91aba35cf7212b0e4b8fbc493e73440888dea14

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)-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],)), 2)
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 fixtureActualExpectedOutcome
fixture 1: ([1, 2, 8, 9],)22Passed
fixture 2: ([9, 1, 2],)22Passed
fixture 3: ([4],)44Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / 708b305cefac4f241e398d6ce6e991ed29828779e4e75fd53ffbb30738ed514f

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

Case digest / 3a32380452dd076e7b969e5abb7931ceb71a0b4b61a505854b218da965fcb438