FAILURE MAP
← Case archive

FA-14146 / Numerical aggregation / Open access

Frequency cosine squared: Frequency vectors are dotted by insertion order rather than matching labels. · case 01

The reduction disagrees with its explicit aggregation oracle.

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

ROOT CAUSE

Frequency vectors are dotted by insertion order rather than matching labels.

THE FAILURE

Frequency vectors are dotted by insertion order rather than matching labels.

Unsuccessful approach: Sorting frequencies independently destroys label alignment.

Case contract

Treat samples as frequency vectors over nominal integer labels. Return squared cosine dot**2/(sum count_a**2 * sum count_b**2) as exact Fraction string. A zero norm on either side returns None.

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(a, b):
    ca,cb=Counter(a),Counter(b)
    keys=set(ca)|set(cb)
    dot=sum(x*y for x,y in zip(ca.values(),cb.values()))
    na=sum(v*v for v in ca.values())
    nb=sum(v*v for v in cb.values())
    return str(Fraction(dot*dot,na*nb)) if na and nb else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([1, 1, 2], [1, 2, 2])), '16/25')
check('regression 2', solve(*([1, 2], [1, 2])), '1')
check('regression 3', solve(*([], [])), None)
check('regression 4', solve(*([0], [1])), '0')
check('regression 5', solve(*([1, 1, 1, 2], [1, 2])), '4/5')
check('regression 6', solve(*([-1, 0, 0], [0, 0, 1, 1])), '2/5')
check('regression 7', solve(*([2, 2], [])), None)
check("variable cosine concentration",solve([0]*N+[1],[0]),str(Fraction(N*N,N*N+1)))
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 116/2516/25Passed
regression 211Passed
regression 3NoneNonePassed
regression 410Failed
regression 54/54/5Passed
regression 69/102/5Failed
regression 7NoneNonePassed
variable cosine concentration1/21/2Passed

SHA-256 / 759a472c67dab9418e883107f868098fb54540ce7b4d01c35e1bc0254184bf79

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(a, b):
    ca,cb=Counter(a),Counter(b)
    keys=set(ca)|set(cb)
    dot=sum(x*y for x,y in zip(sorted(ca.values()),sorted(cb.values())))
    na=sum(v*v for v in ca.values())
    nb=sum(v*v for v in cb.values())
    return str(Fraction(dot*dot,na*nb)) if na and nb else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('regression 1', solve(*([1, 1, 2], [1, 2, 2])), '16/25')
check('regression 2', solve(*([1, 2], [1, 2])), '1')
check('regression 3', solve(*([], [])), None)
check('regression 4', solve(*([0], [1])), '0')
check('regression 5', solve(*([1, 1, 1, 2], [1, 2])), '4/5')
check('regression 6', solve(*([-1, 0, 0], [0, 0, 1, 1])), '2/5')
check('regression 7', solve(*([2, 2], [])), None)
check("variable cosine concentration",solve([0]*N+[1],[0]),str(Fraction(N*N,N*N+1)))
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 1116/25Failed
regression 211Passed
regression 3NoneNonePassed
regression 410Failed
regression 54/54/5Passed
regression 69/102/5Failed
regression 7NoneNonePassed
variable cosine concentration1/21/2Passed

SHA-256 / d7b40122b1d13e96fe7d4abc4a199fad05a19d03ea3d238c9f4deca776f5f2b6

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 8 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

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

Case digest / 7d874cd06ddb66a1dbdd973db72b4f3420b2577bd0341468e6f0a663557ce7bf