Estimating a desk total from a deliberately thinned trade log
A replay system retains every large execution but only one in ten small executions, selected by independent coin flips. The ledger tells you how many executions occurred. The retained payloads tell you their individual processing costs. Can you reconstruct the desk’s total cost without pretending every retained execution represents the same number of trades?
A rare sampled trade gets a larger weight
An observed trade included with probability π represents 1/π similar design-weighted trades.
Make each trade pay its own way in expectation
Treat the day’s costs as fixed. Let indicate retention, with known inclusion probability . Trade contributes to the estimate. Averaging over the logger’s random choices gives . Adding up yields the Horvitz–Thompson estimator
The expectation calculation needs the correct marginal probability for each record. It does not require independent retention. For example, an exact quota and a sequence of independent coin flips can give the same marginal retention rate but different uncertainty.
A four-ticket ledger you can inspect in full
Two large executions cost 40 and 60 units and are always logged. Two small executions cost 3 and 7 units and each is retained independently with probability 0.1. The true total is 110. Here are all possible estimates:
| Small tickets retained | Probability | Estimated total |
|---|---|---|
| Neither | 0.81 | 100 |
| Only the 3 | 0.09 | 130 |
| Only the 7 | 0.09 | 170 |
| Both | 0.01 | 200 |
The expected estimate is . Most days with this same ledger and fresh retention coins would produce 100. The occasional large estimate compensates. An unbiased reconstruction can be quite far from the realized ledger on an individual day.
For independent retention, variances add:
The two small tickets contribute , giving a standard deviation of about 22.85 cost units. If the logger sometimes keeps an entire batch together, covariance terms enter. Knowing only the per-ticket probabilities then suffices for the expectation but generally leaves the variance undetermined.
Two different denominators
To estimate mean cost per execution when is known, divide by four. Its expected value is . If is missing, one option is to estimate the count by the same weighting trick, , then report . This produces a weighted average of the observed costs, but expectation does not pass through a random denominator.
For the four rows above the ratio estimates are , , and . Their probability-weighted mean is about 42.84. In the common first row the inferred desk consists entirely of the two expensive executions. The estimated total and count are each unbiased and their ratio still has substantial bias in this small example.
Check which probability the logger actually recorded
Suppose a ticket first passes the intended 10% sampling gate and then its payload survives an independent 80% delivery gate. Its chance of appearing in the analyst’s file is . A weight of ten would recover only 80% of that ticket’s cost in expectation. If delivery failures depend on payload size in an unknown way, the intended sampling probability alone cannot repair the loss. A class that is never logged has no positive inclusion probability to invert.
Practice
Sampling designKeep the two large tickets and select exactly one of the two small tickets by fair coin. What are the possible estimates?Show answer
Each small ticket has inclusion probability one half. The total estimate is either or , each with probability one half. Its mean is 110 and its variance is 16. Selecting exactly one creates negative dependence between the two inclusion indicators.
UnitsWhat happens if you cap the inverse weight at five under the original 10% scheme?Show answer
Each small ticket contributes only on average. The expected total drops to 105. Weight capping trades away some of the design’s expectation guarantee for smaller swings in the estimate.