Anwar runs a small cloud kitchen in Kozhikode, and a delivery aggregator has asked him to commit to an average delivery time. He has timed twelve deliveries from last week, in minutes: 28, 31, 35, 29, 42, 33, 30, 57, 34, 27, 36, 32. The mean is 34.5. The median is 32.5. He wants to promise “about 35 minutes”, but the aggregator’s contract has a penalty clause, so he would like to know how far off that figure could be. Twelve data points is not many.
The textbook route is a t-interval. It uses the sample standard deviation, here about 8.17, and the standard error of 8.17 divided by the square root of 12, roughly 2.36. With 11 degrees of freedom the critical value is about 2.201, so the 95 percent interval is 34.5 plus or minus 5.2, from about 29.3 to 39.7. That works, but it leans on an assumption: that the average of twelve such times behaves roughly like a bell curve. One delivery took 57 minutes, which makes Anwar wonder. And what if he wants an interval for the median? There is no tidy school formula for that.
The idea: treat the sample as the population
The bootstrap, introduced by Bradley Efron, starts from a cheeky premise. If you cannot go back and collect another week of deliveries, pretend your twelve are a miniature of all deliveries, and re-draw from them.
So take twelve slips of paper, one per delivery time. Draw one, note it, put it back, draw again, twelve times. Because each draw is put back, some deliveries appear twice or three times in a resample and some not at all. Compute the mean of that resample. Suppose it is 36.1. Do it again: 33.0. Again: 38.4. Repeat ten thousand times, which is trivial for a computer, and you get ten thousand means. Sort them and look at the 2.5th and 97.5th percentiles.
Running this on Anwar’s twelve numbers gives a 95 percent percentile interval for the mean of roughly 30.8 to 39.5 minutes. Notice it is not symmetric around 34.5: it stretches further up than down, because of the 57. Resamples that include that delivery two or three times pull the mean up; none can pull it down as far. The t-interval was forced to be symmetric, and the bootstrap showed what the data actually looks like. For the median, the same procedure gives about 29.5 to 35.5, which is narrower, as you would expect given that the median shrugs off the 57.
Your exact numbers will differ slightly from run to run, since the resampling is random. That is fine. More resamples smooth it; a few thousand is usual.
What Anwar can say, and what he cannot
He can say that, based on last week, the average delivery time is plausibly anywhere from about 31 to 39 minutes, and that a promise of 35 is not safe. If the penalty applies above 36, there is a real chance he is on the wrong side of it, and he might negotiate for 38, or look at why that one delivery took 57 minutes.
What he cannot say is that the bootstrap has fixed the smallness of his sample. It has not. It only measures the variation present in those twelve numbers. If last week was unusual, say a clear-weather week with no cricket match traffic, then every resample inherits that bias, and the interval will be confidently wrong about a typical month. The method describes sampling noise, not systematic problems. Twelve observations also may not contain the rare disasters at all; a resample cannot invent a 90-minute delivery that never happened in the data.
Where the bootstrap earns its place
It is most helpful when the statistic is awkward. Medians, percentiles such as the 90th-percentile delivery time, ratios of two averages, the difference in conversion between two groups when the data is lopsided, or a custom business metric made of several parts. Instead of deriving a formula for each, you reuse the same loop: resample, compute, collect, read off percentiles.
It is also easy to explain to a non-statistician, which matters. “We re-ran last week ten thousand times with random reshuffling of which deliveries we saw, and 95 percent of the time the average landed between 31 and 39 minutes” is something a business owner follows.
When it misbehaves
- Very small samples, say under about ten, give unstable intervals that are usually too narrow.
- Extremes, like the maximum, are poorly handled, since a resample can never exceed the largest value you saw.
- Dependent data breaks it. Deliveries on the same rainy evening are related. Resampling them as independent slips understates the uncertainty, and time-series or clustered data need variants that resample blocks or whole groups.
Compare the two intervals again. Where the data are well behaved and plentiful, the bootstrap and the classical formula agree closely, which is reassuring rather than disappointing. Where they differ, as with Anwar’s twelve, the disagreement is itself information: the data are skewed, and the classical assumptions are doing some work.
Figures and names in the examples are illustrative.
Leave a Reply