{"abstract":"The output is the centre sample of the window, i.e. no filtering at all.","category":"Digital signal filters","checks":7,"contract":"Input [K, samples]; K odd (\"bad-kernel\" otherwise). Output i is the median of samples[i-K//2 .. i+K//2] clipped to the valid range (shrinking windows at the edges); an even count uses the mean of the two middle values. Return exact fraction strings.","contract_signature":"x","evaluation_group":"w2-digital_signal_filters-median-filter-shrink","failed_approach":"The attempted repair sorts a de-duplicated set, which changes the median whenever values repeat.","family":"w2-digital_signal_filters-median-filter-shrink-window-ordering","id":"FA-91451","implementations":{"attempt":{"sha256":"1f4bc483476d3f253e5c8adef2987060121ee904210371ad4b2808bc8c1b6b71","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    k, xs = x\n    if k < 1 or k % 2 == 0:\n        return 'bad-kernel'\n    h = k // 2\n    out = []\n    for i in range(len(xs)):\n        win = sorted(set(xs[max(0, i - h):i + h + 1]))\n        m = len(win)\n        if m % 2:\n            out.append(str(Fraction(win[m // 2])))\n        else:\n            out.append(str(Fraction(win[m // 2 - 1] + win[m // 2], 2)))\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: unsorted window', [3, [5, 1, 9, 2]], ['3', '5', '2', '11/2']], ['regression: edge even median', [3, [4, 1, 7]], ['5/2', '4', '4']], ['regression: duplicates', [3, [2, 2, 5, 2]], ['2', '2', '2', '7/2']], ['control: negative odd sum', [3, [-3, 0, 5]], ['-3/2', '0', '5/2']], ['control: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 1', [1, [2, 3, 4, -2]], ['2', '3', '4', '-2']]], [['regression: random median 2', [3, [5, 5, 3, -5, 8, -1]], ['5', '5', '3', '3', '-1', '7/2']], ['regression: random median 6', [3, [3, 9, 2, 4, 6, 3, -4]], ['6', '3', '4', '4', '4', '3', '-1/2']], ['repair check: random median 4', [3, [0, -4, -4, 3]], ['-2', '-4', '-4', '-1/2']], ['control: random median 3', [1, [2, -3, 7, 8, -2, 3, 8, 1]], ['2', '-3', '7', '8', '-2', '3', '8', '1']], ['control: random median 7', [1, [7, 6, 6, -2, 6, 0, 8, -4]], ['7', '6', '6', '-2', '6', '0', '8', '-4']], ['control: random median 8', [1, [2, 8, -4, 9, 7, 7]], ['2', '8', '-4', '9', '7', '7']], ['control: random median 9', [1, [2, 5, 7, 9]], ['2', '5', '7', '9']]], [['regression: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['regression: random median 13', [3, [1, -4, -1, 3, 9, 4, 6, 2]], ['-3/2', '-1', '-1', '3', '4', '6', '4', '4']], ['repair check: random median 5', [3, [2, -2, -2, -2, -4, -4]], ['0', '-2', '-2', '-2', '-4', '-4']], ['control: random median 10', [1, [9, 3, -5, 8]], ['9', '3', '-5', '8']], ['control: random median 14', [1, [2, 8, 6, 5, -4, -3, -1]], ['2', '8', '6', '5', '-4', '-3', '-1']], ['control: random median 15', [1, [8, 2]], ['8', '2']], ['control: random median 17', [1, [-5, -2, -4, 5, 9, 2, -4]], ['-5', '-2', '-4', '5', '9', '2', '-4']]], [['regression: random median 18', [5, [-4, 9, 8, -3, -2]], ['8', '5/2', '-2', '3', '-2']], ['regression: random median 19', [3, [7, 8, -4]], ['15/2', '7', '2']], ['regression: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['control: random median 23', [1, [4, 1, -1, 3, -1]], ['4', '1', '-1', '3', '-1']], ['control: random median 25', [1, [-5, 6]], ['-5', '6']], ['control: random median 26', [3, [-4, 5]], ['1/2', '1/2']], ['control: random median 27', [1, [-2, 5, -4, 7, 1, -3]], ['-2', '5', '-4', '7', '1', '-3']]], [['regression: random median 22', [5, [3, -1, 4, 8, 9]], ['3', '7/2', '4', '6', '8']], ['regression: random median 24', [3, [8, -2, -5, 4, 2]], ['3', '-2', '-2', '2', '3']], ['repair check: random median 20', [3, [-3, -5, -5]], ['-4', '-5', '-5']], ['control: random median 28', [1, [1, -1, 2, 9, 2, 3, 6]], ['1', '-1', '2', '9', '2', '3', '6']], ['control: random median 29', [5, [9, 8, 5]], ['8', '8', '8']], ['control: random median 34', [3, [-1, 5]], ['2', '2']], ['control: random median 35', [1, [-3, 0, 9]], ['-3', '0', '9']]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"28321666975f230bd1cda5814c5492299506eb70bef7c0bd77b3286efbfa16e5","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nfrom fractions import Fraction\nN = 1\nobservations = []\ndef solve(x):\n    k, xs = x\n    if k < 1 or k % 2 == 0:\n        return 'bad-kernel'\n    h = k // 2\n    out = []\n    for i in range(len(xs)):\n        win = list(xs[max(0, i - h):i + h + 1])\n        m = len(win)\n        if m % 2:\n            out.append(str(Fraction(win[m // 2])))\n        else:\n            out.append(str(Fraction(win[m // 2 - 1] + win[m // 2], 2)))\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[['regression: unsorted window', [3, [5, 1, 9, 2]], ['3', '5', '2', '11/2']], ['regression: edge even median', [3, [4, 1, 7]], ['5/2', '4', '4']], ['regression: duplicates', [3, [2, 2, 5, 2]], ['2', '2', '2', '7/2']], ['control: negative odd sum', [3, [-3, 0, 5]], ['-3/2', '0', '5/2']], ['control: even kernel', [2, [1, 2, 3]], 'bad-kernel'], ['control: even kernel four', [4, [1, 5, 2, 8]], 'bad-kernel'], ['control: random median 1', [1, [2, 3, 4, -2]], ['2', '3', '4', '-2']]], [['regression: random median 2', [3, [5, 5, 3, -5, 8, -1]], ['5', '5', '3', '3', '-1', '7/2']], ['regression: random median 6', [3, [3, 9, 2, 4, 6, 3, -4]], ['6', '3', '4', '4', '4', '3', '-1/2']], ['repair check: random median 4', [3, [0, -4, -4, 3]], ['-2', '-4', '-4', '-1/2']], ['control: random median 3', [1, [2, -3, 7, 8, -2, 3, 8, 1]], ['2', '-3', '7', '8', '-2', '3', '8', '1']], ['control: random median 7', [1, [7, 6, 6, -2, 6, 0, 8, -4]], ['7', '6', '6', '-2', '6', '0', '8', '-4']], ['control: random median 8', [1, [2, 8, -4, 9, 7, 7]], ['2', '8', '-4', '9', '7', '7']], ['control: random median 9', [1, [2, 5, 7, 9]], ['2', '5', '7', '9']]], [['regression: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['regression: random median 13', [3, [1, -4, -1, 3, 9, 4, 6, 2]], ['-3/2', '-1', '-1', '3', '4', '6', '4', '4']], ['repair check: random median 5', [3, [2, -2, -2, -2, -4, -4]], ['0', '-2', '-2', '-2', '-4', '-4']], ['control: random median 10', [1, [9, 3, -5, 8]], ['9', '3', '-5', '8']], ['control: random median 14', [1, [2, 8, 6, 5, -4, -3, -1]], ['2', '8', '6', '5', '-4', '-3', '-1']], ['control: random median 15', [1, [8, 2]], ['8', '2']], ['control: random median 17', [1, [-5, -2, -4, 5, 9, 2, -4]], ['-5', '-2', '-4', '5', '9', '2', '-4']]], [['regression: random median 18', [5, [-4, 9, 8, -3, -2]], ['8', '5/2', '-2', '3', '-2']], ['regression: random median 19', [3, [7, 8, -4]], ['15/2', '7', '2']], ['regression: random median 12', [3, [7, 1, -5, -5, -5, 2, 5, -5]], ['4', '1', '-5', '-5', '-5', '2', '2', '0']], ['control: random median 23', [1, [4, 1, -1, 3, -1]], ['4', '1', '-1', '3', '-1']], ['control: random median 25', [1, [-5, 6]], ['-5', '6']], ['control: random median 26', [3, [-4, 5]], ['1/2', '1/2']], ['control: random median 27', [1, [-2, 5, -4, 7, 1, -3]], ['-2', '5', '-4', '7', '1', '-3']]], [['regression: random median 22', [5, [3, -1, 4, 8, 9]], ['3', '7/2', '4', '6', '8']], ['regression: random median 24', [3, [8, -2, -5, 4, 2]], ['3', '-2', '-2', '2', '3']], ['repair check: random median 20', [3, [-3, -5, -5]], ['-4', '-5', '-5']], ['control: random median 28', [1, [1, -1, 2, 9, 2, 3, 6]], ['1', '-1', '2', '9', '2', '3', '6']], ['control: random median 29', [5, [9, 8, 5]], ['8', '8', '8']], ['control: random median 34', [3, [-1, 5]], ['2', '2']], ['control: random median 35', [1, [-3, 0, 9]], ['-3', '0', '9']]]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-digital_signal_filters-median-filter-shrink-window-ordering","generated_at":"2026-09-29T14:51:36.142691+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Median filters remove impulse noise without blurring edges; window or tie handling slips shift features.","root_cause":"The window slice is used in time order rather than sorted.","sha256":"107b1f03449c10c0ea2ab971cb96da679f7c15c14002a2b1b9029128507f2037","title":"Median filter takes the middle sample without sorting · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":43.115,"exit_code":1,"observations":[{"actual":["3","5","2","11/2"],"check":"regression: unsorted window","expected":["3","5","2","11/2"],"passed":true},{"actual":["5/2","4","4"],"check":"regression: edge even median","expected":["5/2","4","4"],"passed":true},{"actual":["2","7/2","7/2","7/2"],"check":"regression: duplicates","expected":["2","2","2","7/2"],"passed":false},{"actual":["-3/2","0","5/2"],"check":"control: negative odd sum","expected":["-3/2","0","5/2"],"passed":true},{"actual":"bad-kernel","check":"control: even kernel","expected":"bad-kernel","passed":true},{"actual":"bad-kernel","check":"control: even kernel four","expected":"bad-kernel","passed":true},{"actual":["2","3","4","-2"],"check":"control: random median 1","expected":["2","3","4","-2"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: unsorted window\", \"actual\": [\"3\", \"5\", \"2\", \"11/2\"], \"expected\": [\"3\", \"5\", \"2\", \"11/2\"], \"passed\": true}, {\"check\": \"regression: edge even median\", \"actual\": [\"5/2\", \"4\", \"4\"], \"expected\": [\"5/2\", \"4\", \"4\"], \"passed\": true}, {\"check\": \"regression: duplicates\", \"actual\": [\"2\", \"7/2\", \"7/2\", \"7/2\"], \"expected\": [\"2\", \"2\", \"2\", \"7/2\"], \"passed\": false}, {\"check\": \"control: negative odd sum\", \"actual\": [\"-3/2\", \"0\", \"5/2\"], \"expected\": [\"-3/2\", \"0\", \"5/2\"], \"passed\": true}, {\"check\": \"control: even kernel\", \"actual\": \"bad-kernel\", \"expected\": \"bad-kernel\", \"passed\": true}, {\"check\": \"control: even kernel four\", \"actual\": \"bad-kernel\", \"expected\": \"bad-kernel\", \"passed\": true}, {\"check\": \"control: random median 1\", \"actual\": [\"2\", \"3\", \"4\", \"-2\"], \"expected\": [\"2\", \"3\", \"4\", \"-2\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.907,"exit_code":1,"observations":[{"actual":["3","1","9","11/2"],"check":"regression: unsorted window","expected":["3","5","2","11/2"],"passed":false},{"actual":["5/2","1","4"],"check":"regression: edge even median","expected":["5/2","4","4"],"passed":false},{"actual":["2","2","5","7/2"],"check":"regression: duplicates","expected":["2","2","2","7/2"],"passed":false},{"actual":["-3/2","0","5/2"],"check":"control: negative odd sum","expected":["-3/2","0","5/2"],"passed":true},{"actual":"bad-kernel","check":"control: even kernel","expected":"bad-kernel","passed":true},{"actual":"bad-kernel","check":"control: even kernel four","expected":"bad-kernel","passed":true},{"actual":["2","3","4","-2"],"check":"control: random median 1","expected":["2","3","4","-2"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: unsorted window\", \"actual\": [\"3\", \"1\", \"9\", \"11/2\"], \"expected\": [\"3\", \"5\", \"2\", \"11/2\"], \"passed\": false}, {\"check\": \"regression: edge even median\", \"actual\": [\"5/2\", \"1\", \"4\"], \"expected\": [\"5/2\", \"4\", \"4\"], \"passed\": false}, {\"check\": \"regression: duplicates\", \"actual\": [\"2\", \"2\", \"5\", \"7/2\"], \"expected\": [\"2\", \"2\", \"2\", \"7/2\"], \"passed\": false}, {\"check\": \"control: negative odd sum\", \"actual\": [\"-3/2\", \"0\", \"5/2\"], \"expected\": [\"-3/2\", \"0\", \"5/2\"], \"passed\": true}, {\"check\": \"control: even kernel\", \"actual\": \"bad-kernel\", \"expected\": \"bad-kernel\", \"passed\": true}, {\"check\": \"control: even kernel four\", \"actual\": \"bad-kernel\", \"expected\": \"bad-kernel\", \"passed\": true}, {\"check\": \"control: random median 1\", \"actual\": [\"2\", \"3\", \"4\", \"-2\"], \"expected\": [\"2\", \"3\", \"4\", \"-2\"], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}