FA-6241 / Statistics / Open access
Sample covariance rational · case 01
The population divisor omits Bessel correction.
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: ([1, 2, 3], [2, 4, 6]) | 4/3 | 2 | Failed |
| fixture 2: ([2, 2], [1, 3]) | 0 | 0 | Passed |
| fixture 3: ([1, 2], [2, 1]) | -1/4 | -1/2 | Failed |
| fixture 4: ([1], [2]) | 0 | None | Failed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: ([1, 2, 3], [2, 4, 6]) | 14 | 2 | Failed |
| fixture 2: ([2, 2], [1, 3]) | 8 | 0 | Failed |
| fixture 3: ([1, 2], [2, 1]) | 4 | -1/2 | Failed |
| fixture 4: ([1], [2]) | None | None | Passed |
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: ([1, 2, 3], [2, 4, 6]) | 2 | 2 | Passed |
| fixture 2: ([2, 2], [1, 3]) | 0 | 0 | Passed |
| fixture 3: ([1, 2], [2, 1]) | -1/2 | -1/2 | Passed |
| fixture 4: ([1], [2]) | None | None | Passed |
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