FA-12616 / Survey sampling estimators / Open access
Calibration matches record counts rather than population margins · case 01
Calibration matches record counts rather than population margins.
ROOT CAUSE
Each poststratum is assigned equal respondent weights ignoring base weights.
VERIFIED REPAIR
Multiply each base weight by known cell population divided by the sum of base weights in that cell.
Unsuccessful approach: Global calibration achieves only the grand total and misses cell margins.
Case contract
Rows are (cell,positive base weight); margins give positive population totals for exactly the represented cells. Return weights in input order rounded to eight decimals; empty inputs return 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, margins):
return [round(margins[c]/sum(k==c for k,v in rows),8) for c,w in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal base weights',solve([('a',N),('a',3*N)],{'a':8*N}),[2*N,6*N])
check('separate margins',solve([('a',N),('b',N)],{'a':2*N,'b':6*N}),[2*N,6*N])
check('already calibrated',solve([('a',N),('a',3*N)],{'a':4*N}),[N,3*N])
check('single observation',solve([('a',N)],{'a':7*N}),[7*N])
check('row order preserved',solve([('b',N),('a',N),('b',3*N)],{'a':2*N,'b':8*N}),[2*N,2*N,6*N])
check('empty cells',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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal base weights | [4.0, 4.0] | [2, 6] | Failed |
| separate margins | [2.0, 6.0] | [2, 6] | Passed |
| already calibrated | [2.0, 2.0] | [1, 3] | Failed |
| single observation | [7.0] | [7] | Passed |
| row order preserved | [4.0, 2.0, 4.0] | [2, 2, 6] | Failed |
| empty cells | [] | [] | Passed |
SHA-256 / ba3f423e108b7523dad10abcfa0475dcf9e24ef8322f49b3ff12c4ebabe29385
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, margins):
total=sum(margins.values()); base=sum(w for c,w in rows)
return [round(w*total/base,8) for c,w in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal base weights',solve([('a',N),('a',3*N)],{'a':8*N}),[2*N,6*N])
check('separate margins',solve([('a',N),('b',N)],{'a':2*N,'b':6*N}),[2*N,6*N])
check('already calibrated',solve([('a',N),('a',3*N)],{'a':4*N}),[N,3*N])
check('single observation',solve([('a',N)],{'a':7*N}),[7*N])
check('row order preserved',solve([('b',N),('a',N),('b',3*N)],{'a':2*N,'b':8*N}),[2*N,2*N,6*N])
check('empty cells',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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal base weights | [2.0, 6.0] | [2, 6] | Passed |
| separate margins | [4.0, 4.0] | [2, 6] | Failed |
| already calibrated | [1.0, 3.0] | [1, 3] | Passed |
| single observation | [7.0] | [7] | Passed |
| row order preserved | [2.0, 2.0, 6.0] | [2, 2, 6] | Passed |
| empty cells | [] | [] | Passed |
SHA-256 / 3193c32390a61f4ac5d701d90f4260f799b99d5fc0ce92b4ec9da67e6de79281
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(rows, margins):
return [round(w*margins[c]/sum(v for k,v in rows if k==c),8) for c,w in rows]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('unequal base weights',solve([('a',N),('a',3*N)],{'a':8*N}),[2*N,6*N])
check('separate margins',solve([('a',N),('b',N)],{'a':2*N,'b':6*N}),[2*N,6*N])
check('already calibrated',solve([('a',N),('a',3*N)],{'a':4*N}),[N,3*N])
check('single observation',solve([('a',N)],{'a':7*N}),[7*N])
check('row order preserved',solve([('b',N),('a',N),('b',3*N)],{'a':2*N,'b':8*N}),[2*N,2*N,6*N])
check('empty cells',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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| unequal base weights | [2.0, 6.0] | [2, 6] | Passed |
| separate margins | [2.0, 6.0] | [2, 6] | Passed |
| already calibrated | [1.0, 3.0] | [1, 3] | Passed |
| single observation | [7.0] | [7] | Passed |
| row order preserved | [2.0, 2.0, 6.0] | [2, 2, 6] | Passed |
| empty cells | [] | [] | Passed |
SHA-256 / bd4ff405ceae221b6bcd86ac59d8bc6b1c70c757c058f8736fdc283e8366d30d
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.585259+00:00.
Case digest / af9ca2dcec14aefc7d397bbc748e1d3d958c70fe9fa4e82efe2d1c1b20218a1e