FAILURE MAP
← Case archive

FA-12611 / Survey sampling estimators / Open access

A global response adjustment transfers weight across response cells · case 01

A global response adjustment transfers weight across response cells.

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

ROOT CAUSE

All response cells share one global response inflation factor.

VERIFIED REPAIR

Within each cell preserve its eligible base-weight total by scaling respondent weights only.

Unsuccessful approach: A cell response-count factor ignores unequal base weights.

Case contract

Rows are (cell, positive base weight, responded boolean). Return adjusted respondent weights in row order; return None if any represented cell has zero respondents. Empty input returns empty list.

Why this case matters

A deterministic survey-design model isolates this sampling contract before it is embedded in a larger estimation pipeline.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rows):
    total=sum(w for c,w,r in rows); observed=sum(w for c,w,r in rows if r)
    return [round(w*total/observed,8) for c,w,r in rows if r] if observed else None
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights within cell',solve([('a',N,True),('a',3*N,False)]),[4*N])
check('different cell response',solve([('a',N,True),('a',N,False),('b',N,True)]),[2*N,N])
check('all response',solve([('a',N,True),('b',2*N,True)]),[N,2*N])
check('cell has no response',solve([('a',N,True),('b',N,False)]),None)
check('preserve respondent proportions',solve([('a',N,True),('a',3*N,True),('a',4*N,False)]),[2*N,6*N])
check('empty frame',solve([]),[])
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
unequal weights within cell[4.0][4]Passed
different cell response[1.5, 1.5][2, 1]Failed
all response[1.0, 2.0][1, 2]Passed
cell has no response[2.0]NoneFailed
preserve respondent proportions[2.0, 6.0][2, 6]Passed
empty frameNone[]Failed

SHA-256 / 3193b2455a93ef7f8b1ca901630135acf7bb4ac9e9a31a812f9ea699e9934556

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rows):
    if any(not any(r for c,w,r in rows if c==cell) for cell in {c for c,w,r in rows}): return None
    return [round(w*sum(c==cell for c,v,r in rows)/sum(c==cell and r for c,v,r in rows),8) for cell,w,r in rows if r]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights within cell',solve([('a',N,True),('a',3*N,False)]),[4*N])
check('different cell response',solve([('a',N,True),('a',N,False),('b',N,True)]),[2*N,N])
check('all response',solve([('a',N,True),('b',2*N,True)]),[N,2*N])
check('cell has no response',solve([('a',N,True),('b',N,False)]),None)
check('preserve respondent proportions',solve([('a',N,True),('a',3*N,True),('a',4*N,False)]),[2*N,6*N])
check('empty frame',solve([]),[])
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
unequal weights within cell[2.0][4]Failed
different cell response[2.0, 1.0][2, 1]Passed
all response[1.0, 2.0][1, 2]Passed
cell has no responseNoneNonePassed
preserve respondent proportions[1.5, 4.5][2, 6]Failed
empty frame[][]Passed

SHA-256 / b08841e4cae6452bbd52457b42c73904194ff6a349a790c853879fa94808cb9d

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rows):
    totals={}; responding={}
    for c,w,r in rows:
        totals[c]=totals.get(c,0)+w
        if r: responding[c]=responding.get(c,0)+w
    if set(totals)-set(responding): return None
    return [round(w*totals[c]/responding[c],8) for c,w,r in rows if r]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal weights within cell',solve([('a',N,True),('a',3*N,False)]),[4*N])
check('different cell response',solve([('a',N,True),('a',N,False),('b',N,True)]),[2*N,N])
check('all response',solve([('a',N,True),('b',2*N,True)]),[N,2*N])
check('cell has no response',solve([('a',N,True),('b',N,False)]),None)
check('preserve respondent proportions',solve([('a',N,True),('a',3*N,True),('a',4*N,False)]),[2*N,6*N])
check('empty frame',solve([]),[])
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
unequal weights within cell[4.0][4]Passed
different cell response[2.0, 1.0][2, 1]Passed
all response[1.0, 2.0][1, 2]Passed
cell has no responseNoneNonePassed
preserve respondent proportions[2.0, 6.0][2, 6]Passed
empty frame[][]Passed

SHA-256 / 3a29277de52ac7da88846eb64d74cba136ace2b941169b41d95270a1848df4b0

Verification & scope

Controlled finite fixtures; not a general survey-analysis package. 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:38:58.532044+00:00.

Case digest / 42ca869041321dad28634e038dabb2747989c5b885e7019194b8372b2d243713