Skip to content
About
Main content

Sampling: cheapest exactly where it is weakest

Why is sampling weakest exactly where defects are costliest?

The arithmetic is unforgiving. To see a defect of prevalence p at least once with confidence 1 − β, you need roughly

the share of rows with the defect
chance of seeing it zero times (confidence 1 − β)
95% confidence99% confidence
Data table
Rows needed to see a defect at least once, by prevalence
Prevalence pseriesRows to sample
095% confidence30M
095% confidence25.2M
095% confidence21.2M
095% confidence17.8M
095% confidence15M
095% confidence12.6M
095% confidence10.6M
095% confidence8.94M
095% confidence7.52M
095% confidence6.33M
095% confidence5.33M
095% confidence4.48M
095% confidence3.77M
095% confidence3.17M
095% confidence2.67M
095% confidence2.25M
095% confidence1.89M
095% confidence1.59M
095% confidence1.34M
095% confidence1.13M
095% confidence947K
095% confidence797K
095% confidence671K
095% confidence564K
095% confidence475K
095% confidence399K
095% confidence336K
095% confidence283K
095% confidence238K
095% confidence200K
095% confidence168K
095% confidence142K
095% confidence119K
095% confidence100K
095% confidence84.4K
095% confidence71K
095% confidence59.8K
095% confidence50.3K
095% confidence42.3K
095% confidence35.6K
095% confidence30K
095% confidence25.2K
095% confidence21.2K
095% confidence17.8K
095% confidence15K
095% confidence12.6K
095% confidence10.6K
095% confidence8.94K
095% confidence7.52K
095% confidence6.33K
0.00195% confidence5.33K
0.00195% confidence4.48K
0.00195% confidence3.77K
0.00195% confidence3.17K
0.00195% confidence2.67K
0.00195% confidence2.25K
0.00295% confidence1.89K
0.00295% confidence1.59K
0.00295% confidence1.34K
0.00395% confidence1.13K
0.00395% confidence947
0.00495% confidence797
0.00495% confidence671
0.00595% confidence564
0.00695% confidence475
0.00895% confidence399
0.00995% confidence336
0.01195% confidence283
0.01395% confidence238
0.01595% confidence200
0.01895% confidence168
0.02195% confidence142
0.02595% confidence119
0.0395% confidence100
0.03695% confidence84.4
0.04295% confidence71
0.0595% confidence59.8
0.0695% confidence50.3
0.07195% confidence42.3
0.08495% confidence35.6
0.195% confidence30
099% confidence46.1M
099% confidence38.7M
099% confidence32.6M
099% confidence27.4M
099% confidence23.1M
099% confidence19.4M
099% confidence16.3M
099% confidence13.7M
099% confidence11.6M
099% confidence9.73M
099% confidence8.19M
099% confidence6.89M
099% confidence5.8M
099% confidence4.88M
099% confidence4.1M
099% confidence3.45M
099% confidence2.91M
099% confidence2.44M
099% confidence2.06M
099% confidence1.73M
099% confidence1.46M
099% confidence1.23M
099% confidence1.03M
099% confidence867K
099% confidence730K
099% confidence614K
099% confidence517K
099% confidence435K
099% confidence366K
099% confidence308K
099% confidence259K
099% confidence218K
099% confidence183K
099% confidence154K
099% confidence130K
099% confidence109K
099% confidence91.9K
099% confidence77.3K
099% confidence65K
099% confidence54.7K
099% confidence46.1K
099% confidence38.7K
099% confidence32.6K
099% confidence27.4K
099% confidence23.1K
099% confidence19.4K
099% confidence16.3K
099% confidence13.7K
099% confidence11.6K
099% confidence9.73K
0.00199% confidence8.19K
0.00199% confidence6.89K
0.00199% confidence5.8K
0.00199% confidence4.88K
0.00199% confidence4.1K
0.00199% confidence3.45K
0.00299% confidence2.91K
0.00299% confidence2.44K
0.00299% confidence2.06K
0.00399% confidence1.73K
0.00399% confidence1.46K
0.00499% confidence1.23K
0.00499% confidence1.03K
0.00599% confidence867
0.00699% confidence730
0.00899% confidence614
0.00999% confidence517
0.01199% confidence435
0.01399% confidence366
0.01599% confidence308
0.01899% confidence259
0.02199% confidence218
0.02599% confidence183
0.0399% confidence154
0.03699% confidence130
0.04299% confidence109
0.0599% confidence91.9
0.0699% confidence77.3
0.07199% confidence65
0.08499% confidence54.7
0.199% confidence46.1

Verifying a sampled row means checking it against the world, not against another table: the invoice behind a payment, the shelf price behind a price row, a person who confirms an address. It is the only proxy in this mechanism that touches what "right" refers to, which is why it costs the most per row. Read the formula backwards and a clean sample makes a claim: if n verified rows show no defect, the is below about 3 ÷ n, with 95% confidence. Three hundred clean rows say "under 1%". They say nothing about 10⁻⁴.

Now add the usual relation between prevalence and severity: Systemic breakage is caught by anything, even a glance. The single mispriced trade, the one account with a wrong identifier, the few rows in the wrong currency: these cost money, and they are exactly the defects that uniform sampling will not find at any budget you would approve.

Two escapes

  1. Stratify. Split the data along whatever dimension defects correlate with (source, region, code path, date) and sample each stratum. A rare global defect becomes a common local one inside the affected stratum.
  2. Sample by value, not by row. Where the stakes are money, verify enough rows to cover a target fraction of the total exposure. Value distributions are usually heavy-tailed (a few very large items hold most of the total), so a few hundred rows can cover most of the money. This is , borrowed from financial audit practice. It is the right default whenever the consequence of a defect scales with a value in the row. Uniform row sampling is the right default only when every row is equally important, which is rarely the case.

Illustration. Among 800 million payment rows, suppose the largest 2,000 rows hold 55% of the money. Checking those 2,000 rows (0.00025% of the rows) covers 55% of the exposure. A uniform sample of 2,000 rows would cover about 0.00025% of it.

Compression: sampling finds defects at a rate of about 1 in n, and severity usually grows as 1 over prevalence, so sample by exposure, not by row.