FAILURE MAP
← Case archive

FA-6196 / Statistics / Open access

Mode smallest tie · case 01

The largest tied mode is selected instead of the smallest.

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

ROOT CAUSE

The largest tied mode is selected instead of the smallest.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return min(set(values),key=lambda x:(-values.count(x),x)) if values else None

Unsuccessful approach: Input order replaces frequency comparison.

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 smallest observation among tied highest-frequency values, or None for empty input. Exact operational definition: min(set(values),key=lambda x:(-values.count(x),x)) 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 max(set(values),key=lambda x:(values.count(x),x)) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([3, 3, 1, 1],)', solve(*([3, 3, 1, 1],)), 1)
check('fixture 2: ([2, 1, 2],)', solve(*([2, 1, 2],)), 2)
check('fixture 3: ([7],)', solve(*([7],)), 7)
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: ([3, 3, 1, 1],)31Failed
fixture 2: ([2, 1, 2],)22Passed
fixture 3: ([7],)77Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / a6c87e6271b0da942f8ceeb5a2a24efab702cd9f98da607c56a758473626959c

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 values[0] if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([3, 3, 1, 1],)', solve(*([3, 3, 1, 1],)), 1)
check('fixture 2: ([2, 1, 2],)', solve(*([2, 1, 2],)), 2)
check('fixture 3: ([7],)', solve(*([7],)), 7)
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: ([3, 3, 1, 1],)31Failed
fixture 2: ([2, 1, 2],)22Passed
fixture 3: ([7],)77Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / fe0cf2de2078a2f4d25e4fec41d448c2780b4e4bf05808207b8abe500759e403

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 min(set(values),key=lambda x:(-values.count(x),x)) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([3, 3, 1, 1],)', solve(*([3, 3, 1, 1],)), 1)
check('fixture 2: ([2, 1, 2],)', solve(*([2, 1, 2],)), 2)
check('fixture 3: ([7],)', solve(*([7],)), 7)
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: ([3, 3, 1, 1],)11Passed
fixture 2: ([2, 1, 2],)22Passed
fixture 3: ([7],)77Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / 243df2a8948b6f8379a29c6d31a98c5c2dd05c7a5520e517896a1971f63b9689

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

Case digest / d7333ab499675fc54727378099fa9bb84d88ef5e7748c1de1013939842e77789