Prevalence Estimation — Design-Based Sampling
By the end of this article, you should be able to: define exposure-weighted prevalence, design a probability sample that's efficient for a rare harm, write the Hansen–Hurwitz estimator and see why it stays unbiased, and know how precise the result is.
Step 1: Meet the problem
A platform wants to know what fraction of the content people actually see violates a safety policy. Call that fraction the prevalence. It sounds simple, but two things make it hard: violations are rare (well under 1% of views), and getting a trustworthy label on a single item is expensive (a careful human or LLM judgment, not a cheap heuristic).
Two tempting shortcuts both fail:
- "Just threshold the safety model's scores and report the fraction above the line." This grades your own homework: the model already removed or down-ranked what it caught, and it scores its own misses low, so you only ever see the harm the model already recognizes. It systematically undercounts.
- "Just take a big uniform random sample and label it." Unbiased, but hopeless for a rare harm. At 0.5% prevalence, a random sample of 2,000 items contains about 10 violations, so the daily estimate swings wildly.
The fix is the same one epidemiologists and census bureaus use: design-based probability sampling with an estimator that corrects for the design.
Step 2: Define exactly what you're estimating
Prevalence should reflect what users experienced, so weight by impressions (views), not by items. One item might get one view or a million; counting items would treat those the same.
Here is the number of impressions of item , and is its policy label. The numerator is impressions on violating content; the denominator is all impressions. This is a ratio of totals, which matters for how we estimate its uncertainty later.