FAILURE MAP
← Case archive

FA-6176 / Statistics / Open access

Sample variance bessel correction · case 01

Population normalization biases the sample variance.

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

ROOT CAUSE

Population normalization biases the sample variance.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(statistics.variance([Fraction(v) for v in values])) if len(values)>1 else None

Unsuccessful approach: Increasing the denominator moves opposite to the Bessel correction.

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. Sample variance bessel correction. Exact operational definition: str(statistics.variance([Fraction(v) for v in values])) if len(values)>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(values):
    return str(statistics.pvariance([Fraction(v) 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],)), '1')
check('fixture 2: ([2, 4],)', solve(*([2, 4],)), '2')
check('fixture 3: ([5, 5, 5],)', solve(*([5, 5, 5],)), '0')
check('fixture 4: ([7],)', solve(*([7],)), 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/31Failed
fixture 2: ([2, 4],)12Failed
fixture 3: ([5, 5, 5],)00Passed
fixture 4: ([7],)0NoneFailed

SHA-256 / 56b0ccabaf43c9adbb2d0e0e113f21b43c52770ad182cc13ef7329b7769ab5b9

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((Fraction(v)-statistics.mean(values))**2 for v in values)/(len(values)+1)) 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],)), '1')
check('fixture 2: ([2, 4],)', solve(*([2, 4],)), '2')
check('fixture 3: ([5, 5, 5],)', solve(*([5, 5, 5],)), '0')
check('fixture 4: ([7],)', solve(*([7],)), 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],)1/21Failed
fixture 2: ([2, 4],)2/32Failed
fixture 3: ([5, 5, 5],)00Passed
fixture 4: ([7],)0NoneFailed

SHA-256 / 5ee6bd48e98e1b6367699b5e2dc2bf13acaa7231f38de5bf84847dbd2368c9f7

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(statistics.variance([Fraction(v) for v in values])) if len(values)>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],)', solve(*([1, 2, 3],)), '1')
check('fixture 2: ([2, 4],)', solve(*([2, 4],)), '2')
check('fixture 3: ([5, 5, 5],)', solve(*([5, 5, 5],)), '0')
check('fixture 4: ([7],)', solve(*([7],)), 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],)11Passed
fixture 2: ([2, 4],)22Passed
fixture 3: ([5, 5, 5],)00Passed
fixture 4: ([7],)NoneNonePassed

SHA-256 / b7c6c387eb8e2277b24d57a795a365ea47688d66867ce9e30d7bb84c18034e08

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

Case digest / f186d78be398e9ed06edc310d9a874e3bb63b7598e882f2e8bc3e7a64d35c6fb