FAILURE MAP
← Case archive

FA-91406 / Digital signal filters / Open access

Running average divides warm-up sums by the full window · case 01

The first W-1 outputs are biased toward zero.

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

ROOT CAUSE

The divisor is always W, even before W samples have arrived.

THE FAILURE

The divisor is always W, even before W samples have arrived.

Unsuccessful approach: The attempted repair divides by max(n, 1) during warm-up, one sample short after the first output.

Case contract

Input [W, samples]; causal moving average using a running sum. During warm-up divide by the number of samples seen (min(n+1, W)). Return exact fraction strings; "bad-window" if W < 1.

Why this case matters

Running-sum boxcars are the cheapest smoothing filter; eviction and warm-up slips bias every early or late sample.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    w, xs = x
    if w < 1:
        return 'bad-window'
    acc = 0
    out = []
    for i, v in enumerate(xs):
        acc += v
        if i >= w:
            acc -= xs[i - w]
        out.append(str(Fraction(acc, w)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: window equals length', [3, [1, 2, 3]], ['1', '3/2', '2']], ['regression: window three long', [3, [3, 0, 3, 6, 0, 9]], ['3', '3/2', '2', '3', '3', '5']], ['regression: random average 1', [2, [-4, -1, -3, 5, -4]], ['-4', '-5/2', '-2', '1', '1/2']], ['control: window one', [1, [3, 1, 4]], ['3', '1', '4']], ['control: bad window', [0, [1]], 'bad-window'], ['control: random average 2', [1, [8, 4, 7]], ['8', '4', '7']], ['control: random average 4', [1, [9, 0, 5, -2, -3, 4]], ['9', '0', '5', '-2', '-3', '4']]], [['regression: random average 1', [2, [-4, -1, -3, 5, -4]], ['-4', '-5/2', '-2', '1', '1/2']], ['regression: random average 3', [3, [5, 2, 8, 7, 6, 1, 1]], ['5', '7/2', '5', '17/3', '7', '14/3', '8/3']], ['regression: random average 7', [4, [-1, -2, 0, 7]], ['-1', '-3/2', '-1', '1']], ['control: random average 5', [1, [0, 1]], ['0', '1']], ['control: random average 6', [1, [-4, 1, 2, -3, 3]], ['-4', '1', '2', '-3', '3']], ['control: random average 12', [3, [0]], ['0']], ['control: random average 14', [1, [1, 5, -1, 2, -3]], ['1', '5', '-1', '2', '-3']]], [['regression: random average 8', [2, [-4]], ['-4']], ['regression: random average 9', [4, [7]], ['7']], ['regression: random average 7', [4, [-1, -2, 0, 7]], ['-1', '-3/2', '-1', '1']], ['control: random average 19', [1, [0, -2, 7, 4, 6, 6, -1]], ['0', '-2', '7', '4', '6', '6', '-1']], ['control: random average 20', [1, [3, 0, -3, 4, 8]], ['3', '0', '-3', '4', '8']], ['control: random average 33', [1, [0, -4, 4, 7, -1, 5]], ['0', '-4', '4', '7', '-1', '5']], ['control: random average 35', [1, [-3, 2]], ['-3', '2']]], [['regression: random average 11', [5, [-1, 3, 3]], ['-1', '1', '5/3']], ['regression: random average 13', [2, [-1]], ['-1']], ['regression: random average 15', [3, [-3, 9, -1, 5, 7, -4]], ['-3', '3', '5/3', '13/3', '11/3', '8/3']], ['control: random average 38', [1, [4, 5, 1, 6, 5, 9]], ['4', '5', '1', '6', '5', '9']], ['control: window one', [1, [3, 1, 4]], ['3', '1', '4']], ['control: bad window', [0, [1]], 'bad-window'], ['control: random average 2', [1, [8, 4, 7]], ['8', '4', '7']]], [['regression: random average 16', [4, [6]], ['6']], ['regression: random average 17', [5, [-3, -2, -2, 6, 7, 9, -4, 5]], ['-3', '-5/2', '-7/3', '-1/4', '6/5', '18/5', '16/5', '23/5']], ['regression: random average 18', [3, [0, -3]], ['0', '-3/2']], ['control: random average 4', [1, [9, 0, 5, -2, -3, 4]], ['9', '0', '5', '-2', '-3', '4']], ['control: random average 5', [1, [0, 1]], ['0', '1']], ['control: random average 6', [1, [-4, 1, 2, -3, 3]], ['-4', '1', '2', '-3', '3']], ['control: random average 12', [3, [0]], ['0']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
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: window equals length['1/3', '1', '2']['1', '3/2', '2']Failed
regression: window three long['1', '1', '2', '3', '3', '5']['3', '3/2', '2', '3', '3', '5']Failed
regression: random average 1['-2', '-5/2', '-2', '1', '1/2']['-4', '-5/2', '-2', '1', '1/2']Failed
control: window one['3', '1', '4']['3', '1', '4']Passed
control: bad windowbad-windowbad-windowPassed
control: random average 2['8', '4', '7']['8', '4', '7']Passed
control: random average 4['9', '0', '5', '-2', '-3', '4']['9', '0', '5', '-2', '-3', '4']Passed

SHA-256 / a42eef6d80134bedd4f023411681b042f3782f14d45f9d8c65b41a930cbe5918

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
from fractions import Fraction
N = 1
observations = []
def solve(x):
    w, xs = x
    if w < 1:
        return 'bad-window'
    acc = 0
    out = []
    for i, v in enumerate(xs):
        acc += v
        if i >= w:
            acc -= xs[i - w]
        out.append(str(Fraction(acc, max(i, 1) if i < w else w)))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: window equals length', [3, [1, 2, 3]], ['1', '3/2', '2']], ['regression: window three long', [3, [3, 0, 3, 6, 0, 9]], ['3', '3/2', '2', '3', '3', '5']], ['regression: random average 1', [2, [-4, -1, -3, 5, -4]], ['-4', '-5/2', '-2', '1', '1/2']], ['control: window one', [1, [3, 1, 4]], ['3', '1', '4']], ['control: bad window', [0, [1]], 'bad-window'], ['control: random average 2', [1, [8, 4, 7]], ['8', '4', '7']], ['control: random average 4', [1, [9, 0, 5, -2, -3, 4]], ['9', '0', '5', '-2', '-3', '4']]], [['regression: random average 1', [2, [-4, -1, -3, 5, -4]], ['-4', '-5/2', '-2', '1', '1/2']], ['regression: random average 3', [3, [5, 2, 8, 7, 6, 1, 1]], ['5', '7/2', '5', '17/3', '7', '14/3', '8/3']], ['regression: random average 7', [4, [-1, -2, 0, 7]], ['-1', '-3/2', '-1', '1']], ['control: random average 5', [1, [0, 1]], ['0', '1']], ['control: random average 6', [1, [-4, 1, 2, -3, 3]], ['-4', '1', '2', '-3', '3']], ['control: random average 12', [3, [0]], ['0']], ['control: random average 14', [1, [1, 5, -1, 2, -3]], ['1', '5', '-1', '2', '-3']]], [['regression: random average 8', [2, [-4]], ['-4']], ['regression: random average 9', [4, [7]], ['7']], ['regression: random average 7', [4, [-1, -2, 0, 7]], ['-1', '-3/2', '-1', '1']], ['control: random average 19', [1, [0, -2, 7, 4, 6, 6, -1]], ['0', '-2', '7', '4', '6', '6', '-1']], ['control: random average 20', [1, [3, 0, -3, 4, 8]], ['3', '0', '-3', '4', '8']], ['control: random average 33', [1, [0, -4, 4, 7, -1, 5]], ['0', '-4', '4', '7', '-1', '5']], ['control: random average 35', [1, [-3, 2]], ['-3', '2']]], [['regression: random average 11', [5, [-1, 3, 3]], ['-1', '1', '5/3']], ['regression: random average 13', [2, [-1]], ['-1']], ['regression: random average 15', [3, [-3, 9, -1, 5, 7, -4]], ['-3', '3', '5/3', '13/3', '11/3', '8/3']], ['control: random average 38', [1, [4, 5, 1, 6, 5, 9]], ['4', '5', '1', '6', '5', '9']], ['control: window one', [1, [3, 1, 4]], ['3', '1', '4']], ['control: bad window', [0, [1]], 'bad-window'], ['control: random average 2', [1, [8, 4, 7]], ['8', '4', '7']]], [['regression: random average 16', [4, [6]], ['6']], ['regression: random average 17', [5, [-3, -2, -2, 6, 7, 9, -4, 5]], ['-3', '-5/2', '-7/3', '-1/4', '6/5', '18/5', '16/5', '23/5']], ['regression: random average 18', [3, [0, -3]], ['0', '-3/2']], ['control: random average 4', [1, [9, 0, 5, -2, -3, 4]], ['9', '0', '5', '-2', '-3', '4']], ['control: random average 5', [1, [0, 1]], ['0', '1']], ['control: random average 6', [1, [-4, 1, 2, -3, 3]], ['-4', '1', '2', '-3', '3']], ['control: random average 12', [3, [0]], ['0']]]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
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: window equals length['1', '3', '3']['1', '3/2', '2']Failed
regression: window three long['3', '3', '3', '3', '3', '5']['3', '3/2', '2', '3', '3', '5']Failed
regression: random average 1['-4', '-5', '-2', '1', '1/2']['-4', '-5/2', '-2', '1', '1/2']Failed
control: window one['3', '1', '4']['3', '1', '4']Passed
control: bad windowbad-windowbad-windowPassed
control: random average 2['8', '4', '7']['8', '4', '7']Passed
control: random average 4['9', '0', '5', '-2', '-3', '4']['9', '0', '5', '-2', '-3', '4']Passed

SHA-256 / 2223aa5a18847a8ca06e34c03c8f4c35e4dcf725fd0a0a2680a88861cc928e61

HELD IN THE MEMBER ARCHIVE

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

This mechanism has 7 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

A deterministic bounded teaching model with a stipulated toy contract; exact rational arithmetic or fixed-decimal rounding keeps outputs strict JSON. It is not a production DSP library and claims no standards conformance. 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:51:35.634492+00:00.

Case digest / 9538f8dae7e8cf0ef16dfe18b25ca081a148cf685c2ec2797f24fc3cf597261e