FAILURE MAP
← Case archive

FA-6326 / Statistics / Open access

Gini mean difference rational · case 01

The sample range replaces average pairwise distance.

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

ROOT CAUSE

The sample range replaces average pairwise distance.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(Fraction(sum(abs(a-b) for a in values for b in values),len(values)**2)) if values else None

Unsuccessful approach: Normalization uses observations rather than ordered observation pairs.

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. Gini mean difference rational. Exact operational definition: str(Fraction(sum(abs(a-b) for a in values for b in 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 str(Fraction(max(values)-min(values),1)) 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, 3],)', solve(*([1, 2, 3],)), '8/9')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([0, 4],)', solve(*([0, 4],)), '2')
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, 3],)28/9Failed
fixture 2: ([5, 5],)00Passed
fixture 3: ([0, 4],)42Failed
fixture 4: ([],)NoneNonePassed

SHA-256 / 0f2adf0123ed81f8cac80b5a6e0e3ad31b5b0da5fcdeba7925c0019a312b2bf5

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(Fraction(sum(abs(a-b) for a in values for b in values),len(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, 3],)', solve(*([1, 2, 3],)), '8/9')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([0, 4],)', solve(*([0, 4],)), '2')
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, 3],)8/38/9Failed
fixture 2: ([5, 5],)00Passed
fixture 3: ([0, 4],)42Failed
fixture 4: ([],)NoneNonePassed

SHA-256 / 3be81af47962cf8541d7e073c26f5d5476ee5b1b137ff958fde9c0389e56b1a2

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(Fraction(sum(abs(a-b) for a in values for b in 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, 3],)', solve(*([1, 2, 3],)), '8/9')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([0, 4],)', solve(*([0, 4],)), '2')
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, 3],)8/98/9Passed
fixture 2: ([5, 5],)00Passed
fixture 3: ([0, 4],)22Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / be6b51472e0b7952038185119335d9ad0d1ad569bdd46ede5ec68a58edd34af0

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

Case digest / 0daee6d8ca881e44767daca499a3fc6b027b76ae363a24966b667e07dd559368