FAILURE MAP
← Case archive

FA-12596 / Survey sampling estimators / Open access

Marginal weights omit the first sampling stage · case 01

Marginal weights omit the first sampling stage.

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

ROOT CAUSE

Only the conditional secondary-unit inclusion probability is inverted.

VERIFIED REPAIR

Multiply primary and conditional secondary inclusion probabilities before inversion.

Unsuccessful approach: Adding stage probabilities double-counts paths and can exceed one.

Case contract

Rows are (value, primary probability, conditional secondary probability), both probabilities in (0,1]; return the total rounded to eight decimals.

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):
    return round(sum(y/q for y,p,q in rows),8)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two half stages',solve([(N,0.5,0.5)]),4*N)
check('certain primary',solve([(N,1,0.25)]),4*N)
check('certain secondary',solve([(N,0.25,1)]),4*N)
check('census both',solve([(N,1,1)]),N)
check('heterogeneous paths',solve([(N,0.5,0.25),(N,1,0.5)]),10*N)
check('no observed units',solve([]),0)
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
two half stages2.04Failed
certain primary4.04Passed
certain secondary1.04Failed
census both1.01Passed
heterogeneous paths6.010Failed
no observed units00Passed

SHA-256 / 3ae5188aa40783930b1eded1f4c782272a1eb7146254295202bf2b0bfd42f7fd

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(rows):
    return round(sum(y/min(1,p+q) for y,p,q in rows),8)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two half stages',solve([(N,0.5,0.5)]),4*N)
check('certain primary',solve([(N,1,0.25)]),4*N)
check('certain secondary',solve([(N,0.25,1)]),4*N)
check('census both',solve([(N,1,1)]),N)
check('heterogeneous paths',solve([(N,0.5,0.25),(N,1,0.5)]),10*N)
check('no observed units',solve([]),0)
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
two half stages1.04Failed
certain primary1.04Failed
certain secondary1.04Failed
census both1.01Passed
heterogeneous paths2.3333333310Failed
no observed units00Passed

SHA-256 / 9a76fa8f3c23343a611268e88b156a9e86bc38c9c10fad647a9683e7ba6e5013

3 / The verified repair

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

N = 1
observations = []
def solve(rows):
    return round(sum(y/(p*q) for y,p,q in rows),8)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('two half stages',solve([(N,0.5,0.5)]),4*N)
check('certain primary',solve([(N,1,0.25)]),4*N)
check('certain secondary',solve([(N,0.25,1)]),4*N)
check('census both',solve([(N,1,1)]),N)
check('heterogeneous paths',solve([(N,0.5,0.25),(N,1,0.5)]),10*N)
check('no observed units',solve([]),0)
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
two half stages4.04Passed
certain primary4.04Passed
certain secondary4.04Passed
census both1.01Passed
heterogeneous paths10.010Passed
no observed units00Passed

SHA-256 / 7d2ce787426c8d87b76f1b36656de174d9aac75c313506981af462df1ff5e78a

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

Case digest / 02221009cc253d7a153033e47d035759162b18c6891dcd2b4b7f0b6879ce7780