FAILURE MAP
← Case archive

FA-6221 / Statistics / Open access

Harmonic mean rational · case 01

The arithmetic mean replaces a reciprocal-domain mean.

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

ROOT CAUSE

The arithmetic mean replaces a reciprocal-domain mean.

VERIFIED REPAIR

Apply the specified mathematical contract directly, preserving all terms and boundary cases: return str(Fraction(len(values),1)/sum(Fraction(1,v) for v in values)) if values and all(v>0 for v in values) else None

Unsuccessful approach: The reciprocal mean is returned without the final reciprocal.

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. Harmonic mean rational. Exact operational definition: str(Fraction(len(values),1)/sum(Fraction(1,v) for v in values)) if values and all(v>0 for v in values) 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(Fraction(sum(values),len(values))) if values else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([2, 6],)', solve(*([2, 6],)), '3')
check('fixture 2: ([4, 4],)', solve(*([4, 4],)), '4')
check('fixture 3: ([0, 3],)', solve(*([0, 3],)), None)
check('fixture 4: ([],)', solve(*([],)), 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: ([2, 6],)43Failed
fixture 2: ([4, 4],)44Passed
fixture 3: ([0, 3],)3/2NoneFailed
fixture 4: ([],)NoneNonePassed

SHA-256 / 33dabd41a1960266e94c93450d8edcdabad53d79cc7aff2980164627e7a28e01

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(1,v) for v in values)/len(values)) if values and all(v>0 for v in values) else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([2, 6],)', solve(*([2, 6],)), '3')
check('fixture 2: ([4, 4],)', solve(*([4, 4],)), '4')
check('fixture 3: ([0, 3],)', solve(*([0, 3],)), None)
check('fixture 4: ([],)', solve(*([],)), 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: ([2, 6],)1/33Failed
fixture 2: ([4, 4],)1/44Failed
fixture 3: ([0, 3],)NoneNonePassed
fixture 4: ([],)NoneNonePassed

SHA-256 / 903e1f3913e39e20a703cd2e7046f7a9079799a936391be3da8b010ceb2ca113

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(Fraction(len(values),1)/sum(Fraction(1,v) for v in values)) if values and all(v>0 for v in values) else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: ([2, 6],)', solve(*([2, 6],)), '3')
check('fixture 2: ([4, 4],)', solve(*([4, 4],)), '4')
check('fixture 3: ([0, 3],)', solve(*([0, 3],)), None)
check('fixture 4: ([],)', solve(*([],)), 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: ([2, 6],)33Passed
fixture 2: ([4, 4],)44Passed
fixture 3: ([0, 3],)NoneNonePassed
fixture 4: ([],)NoneNonePassed

SHA-256 / 548ac513dcb25bc627488a31b82319d948ff400b2b2c09c67a1f092f9f6f999b

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

Case digest / 32d0cc21a438fd229b3ab5bde630b4c029d099fd965b5a9c8c69284e21a8970d