FAILURE MAP
← Case archive

FA-13126 / Numerical aggregation / Open access

Frequency left quantile: The rational target is rounded down before cumulative comparison. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

The rational target is rounded down before cumulative comparison.

VERIFIED REPAIR

Preserve the frequency left quantile contract at the identified reduction decision.

Unsuccessful approach: Nearest rank also rounds some fractional thresholds downward.

Case contract

Rows are integer [value, nonnegative frequency]; 0<=p<=q, q>0. Return the smallest supported value whose cumulative positive frequency reaches p/q of total. At p=0 return minimum positive support. No positive mass returns None.

Why this case matters

Exact bounded examples isolate a reduction defect without floating-point or external-service effects.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=(p*total)//q
    running=0
    for x,w in rows:
        running+=w
        if running>=threshold: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
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
regression 1-8-2Failed
regression 288Passed
regression 318Failed
regression 411Passed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 844Passed
regression 999Passed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / 4d342d099112dd6193a5d79d9f58e59a9661879a13edf7c5a5334e994396bd94

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=round(Fraction(p*total,q))
    running=0
    for x,w in rows:
        running+=w
        if running>=threshold: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
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
regression 1-8-2Failed
regression 288Passed
regression 318Failed
regression 411Passed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 844Passed
regression 999Passed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / aa3b49693465dae40796e794c8a888c91a4903296a4e22326b66eb1457bf3f95

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(rows, p, q):
    rows=sorted((x,w) for x,w in rows if w>0)
    if not rows: return None
    total=sum(w for x,w in rows)
    threshold=Fraction(p,q)*total
    running=0
    for x,w in rows:
        running+=w
        if running>=threshold: return x
    return rows[-1][0]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([(-8, 1), (-2, 1), (3, 1)], 2, 5)), -2)
check('regression 2', solve(*([(1, 2), (8, 5)], 1, 2)), 8)
check('regression 3', solve(*([(1, 1), (8, 2)], 2, 5)), 8)
check('regression 4', solve(*([(9, 1), (1, 3), (5, 2)], 1, 2)), 1)
check('regression 5', solve(*([(8, 0), (2, 1)], 0, 1)), 2)
check('regression 6', solve(*([], 1, 2)), None)
check('regression 7', solve(*([(1, 0), (5, 0)], 1, 2)), None)
check('regression 8', solve(*([(1, 1), (4, 2), (8, 1)], 3, 4)), 4)
check('regression 9', solve(*([(9, 4), (2, 1)], 1, 1)), 9)
check('regression 10', solve(*([(3, 2), (3, 1), (1, 1)], 1, 2)), 3)
check('regression 11', solve(*([(2, 2), (7, 2)], 1, 2)), 2)
check("variable rank",solve([(N,2),(N+4,1)],1,2),N)
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
regression 1-2-2Passed
regression 288Passed
regression 388Passed
regression 411Passed
regression 522Passed
regression 6NoneNonePassed
regression 7NoneNonePassed
regression 844Passed
regression 999Passed
regression 1033Passed
regression 1122Passed
variable rank11Passed

SHA-256 / 551bcdb223f6329978a6042ae9bafef33f637bb02ab4034980f21b6095458761

Verification & scope

Small offline integer/rational inputs only; no performance, statistical inference, or production-library conformance claim. 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:39:03.879672+00:00.

Case digest / 845c479968d4bc552514cac178b9fef8739bb5be8951bc6d26208a737c935a54