Auditing half a ledger changes the standard error
A desk has exactly 100 booked trades. You audit 50 different tickets picked uniformly at random and estimate the fraction with a booking error. Someone treats the 50 error flags as independent coin flips. Imagine taking the same calculation all the way to 100 tickets. What uncertainty could possibly remain about this ledger?
Sampling much of a ledger reduces uncertainty
Simple random sampling without replacement; compare to sampling with replacement.
One draw changes the next
Suppose exactly of the tickets have an error. Treat the ledger as fixed. The randomness comes from drawing a simple random sample without replacement. Write and let indicate an error on the th draw. Every draw has marginal mean and variance . But the chance two specified draws both hit errors is
Subtract and the covariance is . Finding an error consumes one of the available errors. A single pair has only a small negative covariance in a large ledger, but the sample mean uses many pairs.
From a pair to a standard error
In the variance of the sum there are diagonal terms and ordered off-diagonal terms. Dividing by gives
The square root of the last factor corrects the independent-draw standard error. For , and true , the independent-draw value is 4.24 percentage points. The ledger calculation gives 3.02 points. With one draw the correction is one. With all tickets it is zero.
Usually is unknown. An unbiased estimate of the variance uses the sample variance with divisor :
Why does a textbook sometimes show and sometimes ? The first multiplies a population variance defined with divisor (or its sample estimate). The second multiplies the variance of a single uniform draw, defined with divisor . Keep the divisor and the correction together.
Could the audit miss every error?
The variance answers a question about estimation. A desk might care more about detection. If there are just two bad tickets in the 100, a sample of 50 misses them both precisely when both land among the 50 unchecked tickets. Its probability is
Independent draws with replacement would miss with probability . Rechecking the same clean ticket wastes a chance to discover a new error. For bad tickets the exact miss probability is , interpreted as zero if fewer than clean tickets exist.
from math import comb
def miss_probability(total, errors, checked):
if not (0 <= errors <= total and 0 <= checked <= total):
raise ValueError("counts must fit the ledger")
return comb(total - errors, checked) / comb(total, checked)
# Smallest audit with at least 95% detection if there are two errors
print(next(n for n in range(101) if miss_probability(100, 2, n) <= 0.05))
The answer is 78. At 77 checks, the chance both errors sit in the remaining 23 tickets is , just above 5%. This is a design calculation conditional on two errors. An audit finding zero errors still leaves the unchecked tickets unresolved.
Practice
ScopeAfter checking the entire ledger, can you forecast tomorrow's error rate with zero uncertainty?Show answer
The census gives today’s realized fraction exactly. Tomorrow adds a new set of trades and possibly a different booking process. Uncertainty about that process survives a census of today.
ImplementationThe file arrives in one pass and its final size is unknown. How can you obtain the uniform sample this derivation assumes?Show answer
Use reservoir sampling with the desired audit capacity and an external end-of-file signal. Every size- subset then has equal probability, so the finite-population calculation applies once the file is complete.