FA-6246 / Statistics / Open access
Linear regression slope rational · case 01
The ratio of means incorrectly forces the fitted line through zero.
ROOT CAUSE
The ratio of means incorrectly forces the fitted line through zero.
VERIFIED REPAIR
Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(Fraction(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(a*a for a in x)-sum(x)**2)) if len(x)*sum(a*a for a in x)!=sum(x)**2 else None
Unsuccessful approach: Dependent-variable variance replaces independent-variable variance.
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. Fit y=intercept+slope*x by least squares; return None when x variance is zero, including empty input. Exact operational definition: str(Fraction(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(a*a for a in x)-sum(x)**2)) if len(x)*sum(a*a for a in x)!=sum(x)**2 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(y),sum(x))) if sum(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], [3, 5, 7])', solve(*([1, 2, 3], [3, 5, 7])), '2')
check('fixture 2: ([1, 2, 3], [3, 2, 1])', solve(*([1, 2, 3], [3, 2, 1])), '-1')
check('fixture 3: ([1, 1], [2, 3])', solve(*([1, 1], [2, 3])), None)
check('fixture 4: ([0, 1], [2, 2])', solve(*([0, 1], [2, 2])), '0')
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], [3, 5, 7]) | 5/2 | 2 | Failed |
| fixture 2: ([1, 2, 3], [3, 2, 1]) | 1 | -1 | Failed |
| fixture 3: ([1, 1], [2, 3]) | 5/2 | None | Failed |
| fixture 4: ([0, 1], [2, 2]) | 4 | 0 | Failed |
SHA-256 / b5c822a33bc653dc7f35baf9fd8ebfc8a45c78c2e38523f6a1615638dce0a05a
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(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(b*b for b in y)-sum(y)**2)) if len(x)*sum(b*b for b in y)!=sum(y)**2 else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7])', solve(*([1, 2, 3], [3, 5, 7])), '2')
check('fixture 2: ([1, 2, 3], [3, 2, 1])', solve(*([1, 2, 3], [3, 2, 1])), '-1')
check('fixture 3: ([1, 1], [2, 3])', solve(*([1, 1], [2, 3])), None)
check('fixture 4: ([0, 1], [2, 2])', solve(*([0, 1], [2, 2])), '0')
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], [3, 5, 7]) | 1/2 | 2 | Failed |
| fixture 2: ([1, 2, 3], [3, 2, 1]) | -1 | -1 | Passed |
| fixture 3: ([1, 1], [2, 3]) | 0 | None | Failed |
| fixture 4: ([0, 1], [2, 2]) | None | 0 | Failed |
SHA-256 / 1723bf98656ba35378e04bf30d78e1f21d9dfaf7f0ad60fc809178bac0bcf034
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(len(x)*sum(a*b for a,b in zip(x,y))-sum(x)*sum(y),len(x)*sum(a*a for a in x)-sum(x)**2)) if len(x)*sum(a*a for a in x)!=sum(x)**2 else None
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([1, 2, 3], [3, 5, 7])', solve(*([1, 2, 3], [3, 5, 7])), '2')
check('fixture 2: ([1, 2, 3], [3, 2, 1])', solve(*([1, 2, 3], [3, 2, 1])), '-1')
check('fixture 3: ([1, 1], [2, 3])', solve(*([1, 1], [2, 3])), None)
check('fixture 4: ([0, 1], [2, 2])', solve(*([0, 1], [2, 2])), '0')
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], [3, 5, 7]) | 2 | 2 | Passed |
| fixture 2: ([1, 2, 3], [3, 2, 1]) | -1 | -1 | Passed |
| fixture 3: ([1, 1], [2, 3]) | None | None | Passed |
| fixture 4: ([0, 1], [2, 2]) | 0 | 0 | Passed |
SHA-256 / 11003650346ceae33747e10e6a637ad5df5eabeb82e904b0f9883fe2068916d5
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.417271+00:00.
Case digest / 2a5ae9ca5f21d4fcdc5f52076631f10f24cec48cba0054c6f7fd12b7a533836d