FAILURE MAP
← Case archive

FA-6211 / Statistics / Open access

Mean absolute deviation about mean · case 01

The absolute mean is substituted for average absolute residual.

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

ROOT CAUSE

The absolute mean is substituted for average absolute residual.

VERIFIED REPAIR

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

Unsuccessful approach: Residuals are accumulated but not normalized by count.

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. Mean absolute deviation about mean. Exact operational definition: str(sum(abs(Fraction(v)-Fraction(sum(values),len(values))) for v in values)/len(values)) 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(abs(Fraction(sum(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],)), '2/3')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([-2, 2],)', solve(*([-2, 2],)), '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],)22/3Failed
fixture 2: ([5, 5],)50Failed
fixture 3: ([-2, 2],)02Failed
fixture 4: ([],)NoneNonePassed

SHA-256 / 439e2059a370fb9e23ad203a5f4848e8118610b78f887d11adea11e1c0affa3e

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

SHA-256 / d0ce88422ebce17273183cbe145019280810e63217d1a78a684324103777c2bf

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(sum(abs(Fraction(v)-Fraction(sum(values),len(values))) for v 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],)), '2/3')
check('fixture 2: ([5, 5],)', solve(*([5, 5],)), '0')
check('fixture 3: ([-2, 2],)', solve(*([-2, 2],)), '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],)2/32/3Passed
fixture 2: ([5, 5],)00Passed
fixture 3: ([-2, 2],)22Passed
fixture 4: ([],)NoneNonePassed

SHA-256 / 7103ea07a43838f6accda37e52241103710c7ffdcb9ac9797b93fa1a0846f62a

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

Case digest / 92e006c4e070ef926bb81003ce3a0daad8b45dee1ac42cb8a7e1bc984edf4228