FAILURE MAP
← Case archive

FA-6266 / Statistics / Open access

Mean squared error · case 01

Averaging before squaring permits residual cancellation.

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

ROOT CAUSE

Averaging before squaring permits residual cancellation.

THE FAILURE

Averaging before squaring permits residual cancellation.

Unsuccessful approach: Absolute residuals implement a different loss.

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. Paired arrays are nonempty; average squared prediction residuals. Exact operational definition: str(Fraction(sum((a-p)**2 for a,p in zip(actual,predicted)),len(actual)))

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(actual, predicted):
    return str(Fraction(sum(a-p for a,p in zip(actual,predicted)),len(actual))**2)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '4')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '3')
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, 3], [2, 2])01Failed
fixture 2: ([0, 0], [2, -2])04Failed
fixture 3: ([1], [1])00Passed
fixture 4: ([1, 2, 3], [1, 2, 6])13Failed

SHA-256 / 00f96a0b117eecd8f5336ffeedc2340c0d611e305b63b9ad2bfc0d43e28802d0

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(actual, predicted):
    return str(Fraction(sum(abs(a-p) for a,p in zip(actual,predicted)),len(actual)))
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 3], [2, 2])', solve(*([1, 3], [2, 2])), '1')
check('fixture 2: ([0, 0], [2, -2])', solve(*([0, 0], [2, -2])), '4')
check('fixture 3: ([1], [1])', solve(*([1], [1])), '0')
check('fixture 4: ([1, 2, 3], [1, 2, 6])', solve(*([1, 2, 3], [1, 2, 6])), '3')
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, 3], [2, 2])11Passed
fixture 2: ([0, 0], [2, -2])24Failed
fixture 3: ([1], [1])00Passed
fixture 4: ([1, 2, 3], [1, 2, 6])13Failed

SHA-256 / fa83a3d61905051baadbbf48424318c953ee8b99423bb6b0ba8d6dcb458ac4da

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 4 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / f388f8016e4bb9b493a321a16434115be15d7b35eb6a320b4010200d29bdb221