FAILURE MAP
← Case archive

FA-6241 / Statistics / Open access

Sample covariance rational · case 01

The population divisor omits Bessel correction.

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

ROOT CAUSE

The population divisor omits Bessel correction.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/(len(x)-1)) if len(x)>1 else None

Unsuccessful approach: Dividing the uncentered cross moment does not compute covariance.

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 None for fewer than two paired observations; otherwise normalize centered products by n-1. Exact operational definition: str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/(len(x)-1)) if len(x)>1 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(x, y):
    return str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/len(x)) if x else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '2')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/2')
check('fixture 4: ([1], [2])', solve(*([1], [2])), 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, 4, 6])4/32Failed
fixture 2: ([2, 2], [1, 3])00Passed
fixture 3: ([1, 2], [2, 1])-1/4-1/2Failed
fixture 4: ([1], [2])0NoneFailed

SHA-256 / 9c8dc17998024c4acadaa6e791e6d1906fae1a84b1d2ff7a1a2bea1193489053

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(x, y):
    return str(Fraction(sum(a*b for a,b in zip(x,y)),len(x)-1)) if len(x)>1 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '2')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/2')
check('fixture 4: ([1], [2])', solve(*([1], [2])), 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, 4, 6])142Failed
fixture 2: ([2, 2], [1, 3])80Failed
fixture 3: ([1, 2], [2, 1])4-1/2Failed
fixture 4: ([1], [2])NoneNonePassed

SHA-256 / 8f93dd2cf7e0a779a8e38ef6aaa5ae8b36c1b128f31c08cc95f9186f22405106

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(x, y):
    return str((Fraction(sum(a*b for a,b in zip(x,y)))-Fraction(sum(x)*sum(y),len(x)))/(len(x)-1)) if len(x)>1 else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [2, 4, 6])', solve(*([1, 2, 3], [2, 4, 6])), '2')
check('fixture 2: ([2, 2], [1, 3])', solve(*([2, 2], [1, 3])), '0')
check('fixture 3: ([1, 2], [2, 1])', solve(*([1, 2], [2, 1])), '-1/2')
check('fixture 4: ([1], [2])', solve(*([1], [2])), 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, 4, 6])22Passed
fixture 2: ([2, 2], [1, 3])00Passed
fixture 3: ([1, 2], [2, 1])-1/2-1/2Passed
fixture 4: ([1], [2])NoneNonePassed

SHA-256 / e86866bcd02b962c3e6c860475a81e624ba267336f57be317af4f5184fc2212b

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

Case digest / 9ae60188008241e8964ee48ba1dc0a85504394431ca1946f439094349ad7b616