FAILURE MAP
← Case archive

FA-13011 / Numerical aggregation / Open access

Merge central moment 4: The fourth-moment merger drops accumulated within-block fourth moment. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

The fourth-moment merger drops accumulated within-block fourth moment.

VERIFIED REPAIR

Preserve the merge central moment 4 contract at the identified reduction decision.

Unsuccessful approach: Keeping only the old block drops incoming fourth moment.

Case contract

Merge disjoint integer observation blocks into [count, exact mean, unnormalised central moments through order 4]. Empty blocks are identities; moments are Fraction strings, empty summary is zero.

Why this case matters

Exact bounded examples isolate a reduction defect without floating-point or external-service effects.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(blocks):
    n=0
    mean=Fraction(0)
    m2=Fraction(0)
    m3=Fraction(0)
    m4=Fraction(0)
    for xs in blocks:
        if not xs: continue
        b=len(xs)
        u=Fraction(sum(xs),b)
        q2=sum((Fraction(x)-u)**2 for x in xs)
        q3=sum((Fraction(x)-u)**3 for x in xs)
        q4=sum((Fraction(x)-u)**4 for x in xs)
        t=n+b
        d=u-mean
        r4=q4+d**4*n*b*(n*n-n*b+b*b)/t**3+6*d*d*(n*n*q2+b*b*m2)/t**2+4*d*(n*q3-b*m3)/t
        r3=m3+q3+d**3*n*b*(n-b)/t**2+3*d*(n*q2-b*m2)/t
        r2=m2+q2+d*d*n*b/t
        mean=mean+d*b/t
        n=t
        m2,m3,m4=r2,r3,r4
    return [n,str(mean),str(m2),str(m3),str(m4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[8], [1, 3]],)), [3, '4', '26', '36', '338'])
check('regression 2', solve(*([[1, 3], [8]],)), [3, '4', '26', '36', '338'])
check('regression 3', solve(*([[0, 0], [0]],)), [3, '0', '0', '0', '0'])
check('regression 4', solve(*([],)), [0, '0', '0', '0', '0'])
check('regression 5', solve(*([[2, 2, 2], [], [-1, 5]],)), [5, '2', '18', '0', '162'])
check('regression 6', solve(*([[-4], [1, 3], [7, 9]],)), [5, '16/5', '524/5', '-3348/25', '506372/125'])
check("variable repeated symmetric blocks",solve([[0,2]]*N),[2*N,"1",str(2*N),"0",str(2*N)])
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
regression 1[3, '4', '26', '36', '338'][3, '4', '26', '36', '338']Passed
regression 2[3, '4', '26', '36', '336'][3, '4', '26', '36', '338']Failed
regression 3[3, '0', '0', '0', '0'][3, '0', '0', '0', '0']Passed
regression 4[0, '0', '0', '0', '0'][0, '0', '0', '0', '0']Passed
regression 5[5, '2', '18', '0', '162'][5, '2', '18', '0', '162']Passed
regression 6[5, '16/5', '524/5', '-3348/25', '464122/125'][5, '16/5', '524/5', '-3348/25', '506372/125']Failed
variable repeated symmetric blocks[2, '1', '2', '0', '2'][2, '1', '2', '0', '2']Passed

SHA-256 / 2b8e3fec6a22c1e4cdc1c633a65a525f7042f98350b2e613eaeeab41e921488f

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(blocks):
    n=0
    mean=Fraction(0)
    m2=Fraction(0)
    m3=Fraction(0)
    m4=Fraction(0)
    for xs in blocks:
        if not xs: continue
        b=len(xs)
        u=Fraction(sum(xs),b)
        q2=sum((Fraction(x)-u)**2 for x in xs)
        q3=sum((Fraction(x)-u)**3 for x in xs)
        q4=sum((Fraction(x)-u)**4 for x in xs)
        t=n+b
        d=u-mean
        r4=m4+d**4*n*b*(n*n-n*b+b*b)/t**3+6*d*d*(n*n*q2+b*b*m2)/t**2+4*d*(n*q3-b*m3)/t
        r3=m3+q3+d**3*n*b*(n-b)/t**2+3*d*(n*q2-b*m2)/t
        r2=m2+q2+d*d*n*b/t
        mean=mean+d*b/t
        n=t
        m2,m3,m4=r2,r3,r4
    return [n,str(mean),str(m2),str(m3),str(m4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[8], [1, 3]],)), [3, '4', '26', '36', '338'])
check('regression 2', solve(*([[1, 3], [8]],)), [3, '4', '26', '36', '338'])
check('regression 3', solve(*([[0, 0], [0]],)), [3, '0', '0', '0', '0'])
check('regression 4', solve(*([],)), [0, '0', '0', '0', '0'])
check('regression 5', solve(*([[2, 2, 2], [], [-1, 5]],)), [5, '2', '18', '0', '162'])
check('regression 6', solve(*([[-4], [1, 3], [7, 9]],)), [5, '16/5', '524/5', '-3348/25', '506372/125'])
check("variable repeated symmetric blocks",solve([[0,2]]*N),[2*N,"1",str(2*N),"0",str(2*N)])
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
regression 1[3, '4', '26', '36', '336'][3, '4', '26', '36', '338']Failed
regression 2[3, '4', '26', '36', '336'][3, '4', '26', '36', '338']Failed
regression 3[3, '0', '0', '0', '0'][3, '0', '0', '0', '0']Passed
regression 4[0, '0', '0', '0', '0'][0, '0', '0', '0', '0']Passed
regression 5[5, '2', '18', '0', '0'][5, '2', '18', '0', '162']Failed
regression 6[5, '16/5', '524/5', '-3348/25', '505872/125'][5, '16/5', '524/5', '-3348/25', '506372/125']Failed
variable repeated symmetric blocks[2, '1', '2', '0', '0'][2, '1', '2', '0', '2']Failed

SHA-256 / bec96fb40a19507aaa32a367e772867eddf20f3654289e4a185f152aca12044e

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
from collections import Counter, defaultdict
import math
import itertools
N = 1
observations = []
def solve(blocks):
    n=0
    mean=Fraction(0)
    m2=Fraction(0)
    m3=Fraction(0)
    m4=Fraction(0)
    for xs in blocks:
        if not xs: continue
        b=len(xs)
        u=Fraction(sum(xs),b)
        q2=sum((Fraction(x)-u)**2 for x in xs)
        q3=sum((Fraction(x)-u)**3 for x in xs)
        q4=sum((Fraction(x)-u)**4 for x in xs)
        t=n+b
        d=u-mean
        r4=m4+q4+d**4*n*b*(n*n-n*b+b*b)/t**3+6*d*d*(n*n*q2+b*b*m2)/t**2+4*d*(n*q3-b*m3)/t
        r3=m3+q3+d**3*n*b*(n-b)/t**2+3*d*(n*q2-b*m2)/t
        r2=m2+q2+d*d*n*b/t
        mean=mean+d*b/t
        n=t
        m2,m3,m4=r2,r3,r4
    return [n,str(mean),str(m2),str(m3),str(m4)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([[8], [1, 3]],)), [3, '4', '26', '36', '338'])
check('regression 2', solve(*([[1, 3], [8]],)), [3, '4', '26', '36', '338'])
check('regression 3', solve(*([[0, 0], [0]],)), [3, '0', '0', '0', '0'])
check('regression 4', solve(*([],)), [0, '0', '0', '0', '0'])
check('regression 5', solve(*([[2, 2, 2], [], [-1, 5]],)), [5, '2', '18', '0', '162'])
check('regression 6', solve(*([[-4], [1, 3], [7, 9]],)), [5, '16/5', '524/5', '-3348/25', '506372/125'])
check("variable repeated symmetric blocks",solve([[0,2]]*N),[2*N,"1",str(2*N),"0",str(2*N)])
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
regression 1[3, '4', '26', '36', '338'][3, '4', '26', '36', '338']Passed
regression 2[3, '4', '26', '36', '338'][3, '4', '26', '36', '338']Passed
regression 3[3, '0', '0', '0', '0'][3, '0', '0', '0', '0']Passed
regression 4[0, '0', '0', '0', '0'][0, '0', '0', '0', '0']Passed
regression 5[5, '2', '18', '0', '162'][5, '2', '18', '0', '162']Passed
regression 6[5, '16/5', '524/5', '-3348/25', '506372/125'][5, '16/5', '524/5', '-3348/25', '506372/125']Passed
variable repeated symmetric blocks[2, '1', '2', '0', '2'][2, '1', '2', '0', '2']Passed

SHA-256 / 0cbf8a3a5129805fbd5df6449ef287e4dafa20edeb03ca8dfde38e6cc41f3e7c

Verification & scope

Small offline integer/rational inputs only; no performance, statistical inference, or production-library conformance claim. 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:39:02.438296+00:00.

Case digest / 47a90a5247cda8983d7785ca53b1913ffcc8e504cf3fbd1818073a9e96936152