Correcting Size-Biased Sampling to Estimate Daily Guest Totals
Statistics & ExperimentsModel answerLast updated
Estimate total guests who show up across all reservations from a sample drawn proportionally to party size, correcting the bias and giving a confidence interval.
A venue has 10,000 bookings for one day. For booking j you have:
- the booked party size (R_j), a positive integer, and
- the number of guests who actually arrive, (S_j), which may be smaller than, equal to, or larger than (R_j).
Checking actual arrivals is expensive, so you only record ((R_i, S_i)) for 1,000 bookings. The bookings were chosen with probability proportional to booked party size. For example, a booking for 10 is twice as likely to be picked as a booking for 5:
[ \Pr(\text{booking } j \text{ is selected}) \propto R_j . ]
Task. Using only the 1,000 observed pairs, estimate the total number of guests who show up across all 10,000 bookings:
[ T_S = \sum_{j=1}^{10000} S_j . ]
You should:
- Explain why the obvious estimate (10,000 times the average of the sampled (S_i)) goes wrong.
- Give an estimator that corrects for the sampling design, and say what extra information it needs.
- State the assumptions you rely on.
- Describe how you would quantify uncertainty, for example with a 95% confidence interval.
Hints
Hint 1
Write down the probability that a single draw selects booking j. What does the plain sample mean of S estimate under that probability, and how does it compare with the true average of S over all bookings?
Hint 2
Rewrite the target as a sum of R_j times the ratio S_j / R_j. Under size-proportional sampling, which simple sample average of per-booking quantities is unbiased for a weighted version of this?
Hint 3
The correction needs a known population quantity: the total booked size (available from the booking system), or at least N. For the variance, treat each scaled term as an i.i.d. draw and use its sample standard deviation, or bootstrap the pairs.
Model answer
Easy Try it yourself first — then compare your approach, complexity and edge cases.
Why the naive estimate is wrong
Let (R_{\text{tot}} = \sum_j R_j). With size-proportional sampling, each draw picks booking j with probability
$$p_j = \frac{R_j}{R_{\text{tot}}}.$$
The sample mean of (S) therefore targets
$$E[S_i] = \sum_j \frac{R_j}{R_{\text{tot}}} S_j,$$
a party-size-weighted average of arrivals, not the plain average (T_S/N). Because larger bookings usually bring more people, the weighted average is larger. So (N \cdot \bar S) overestimates (T_S).
Corrected estimator (inverse-probability weighting)
Weight each observation by the inverse of its selection probability (the Hansen–Hurwitz idea):
$$\hat T_S = \frac1n \sum_{i=1}^n \frac{S_i}{p_i} = R_{\text{tot}} \cdot \frac1n \sum_{i=1}^n \frac{S_i}{R_i}.$$
Unbiasedness. For one draw,
$$E!\left[\frac{S_i}{R_i}\right] = \sum_j \frac{R_j}{R_{\text{tot}}}\cdot \frac{S_j}{R_j} = \frac{T_S}{R_{\text{tot}}},$$
so (E[\hat T_S] = T_S).
Intuition. (T_S = \sum_j R_j \cdot (S_j/R_j)) is the total booked size times the seat-weighted average show-up ratio. Sampling proportional to seats already gives that weighting, so the plain mean of the ratios (S_i/R_i) is the right quantity to average. Multiply by (R_{\text{tot}}) to get back to head-count.
If only N is known
The booking system normally knows every (R_j), so (R_{\text{tot}}) is known. If it were not, note that
$$E!\left[\frac1{R_i}\right] = \frac{N}{R_{\text{tot}}},$$
so (\hat R_{\text{tot}} = nN / \sum_i (1/R_i)). Plugging in gives a Hájek-type ratio estimator:
$$\hat T_S^{\text{ratio}} = N \cdot \frac{\sum_i S_i/R_i}{\sum_i 1/R_i}.$$
It is a weighted mean of (S_i) with weights (1/R_i), scaled by (N). It is consistent, with a small (O(1/n)) bias that is negligible at (n=1000). Some known population total is always needed, otherwise the overall scale is not identified.
Uncertainty
Known (R_{\text{tot}}). Define (y_i = R_{\text{tot}} S_i/R_i). Under with-replacement sampling these are i.i.d. and (\hat T_S = \bar y), so
$$\widehat{SE} = \frac{s_y}{\sqrt n}, \qquad \text{95% CI} = \hat T_S \pm 1.96,\widehat{SE}.$$
Example. If (R_{\text{tot}} = 40{,}000), the mean of (S/R) is 0.92 and its SD is 0.30:
- (\hat T_S = 36{,}800)
- (SE = 40{,}000 \times 0.30/\sqrt{1000} \approx 380)
- 95% CI (\approx 36{,}800 \pm 744)
Unknown (R_{\text{tot}}). Use the delta method, or simply a bootstrap: resample the 1,000 pairs with replacement, recompute the ratio estimator each time, and take the 2.5th and 97.5th percentiles. The bootstrap is also safer if (S/R) is skewed (for instance walk-ins joining small bookings).
Without-replacement sampling. The sampling fraction is 10%, so multiplying the variance by the finite-population correction (1 - n/N \approx 0.9) is a reasonable approximation. An exact variance for PPS without replacement needs joint inclusion probabilities.
Assumptions
- Selection probability is exactly proportional to (R_j) and does not depend on (S_j) (otherwise no-shows or over-shows being measured differently biases the result).
- (R_j > 0) for all bookings.
- (R_{\text{tot}}) (or at least (N)) is known.
- (S) is measured without error for sampled bookings.
- Draws are effectively independent, or the finite-population correction is applied.
- (n) is large enough for a normal approximation; otherwise bootstrap.
Code
import numpy as np
def estimate_total_guests(R, S, R_total=None, N=None, n_boot=2000, seed=0):
R = np.asarray(R, float)
S = np.asarray(S, float)
n = len(R)
ratio = S / R
if R_total is not None:
y = R_total * ratio
est = y.mean()
se = y.std(ddof=1) / np.sqrt(n)
return est, (est - 1.96 * se, est + 1.96 * se)
def ratio_est(idx):
return N * ratio[idx].sum() / (1.0 / R[idx]).sum()
est = ratio_est(np.arange(n))
rng = np.random.default_rng(seed)
boots = [ratio_est(rng.integers(0, n, n)) for _ in range(n_boot)]
return est, tuple(np.percentile(boots, [2.5, 97.5]))
Complexity is (O(n)) for the point estimate and (O(n \cdot B)) for the bootstrap.
Possible improvement
All (R_j) are known, so fit a model of (S/R) on (R) (and time slot, weekday, etc.) using the sample, predict for every booking, and add a weighted residual correction from the sample (a GREG, model-assisted estimator). It remains approximately design-unbiased and can cut variance considerably.
Common mistakes
- Using (N\bar S): ignores the design and is biased upward.
- Weighting by (R_i) instead of (1/R_i): amplifies the bias.
- Using (R_{\text{tot}} \cdot \bar S/\bar R) (the simple-random-sampling ratio estimator): biased here; the correct quantity is the mean of the ratios, (\overline{S/R}).
- Not stating that (R_{\text{tot}}) or (N) must be known.
- Reporting a point estimate with no interval, or ignoring the finite-population correction when 10% of the population is sampled.