Wave Seven · Chance — a stochastic law, rendered
A fair sample of a river you can only see once.
An endless stream slides past and you may keep only seven of it — each item glimpsed a single time, no rewinding, no knowing the total. Reservoir sampling answers the impossible-seeming ask: take each new arrival with fading odds of one-in-n and the seven cups you hold stay a perfectly uniform sample of everything the river has ever carried.
The trick / Algorithm R
Constant memory. No count of the whole. Still exactly fair.
Three moves keep the cups honest against a stream of any length — even one that never ends.
Fill the cups
The first seven arrivals take the cups outright. With nothing yet to compare against, everyone seen so far is simply kept.
Weigh the knock
Arrival number n knocks with odds of seven in n. Early on that is near-certain; a thousand items deep, it is a long shot — and rightly so.
Evict at random
A knock that is answered evicts one cup, chosen uniformly. The evicted item rejoins the current and is gone for good.
The proof / every position, level
The first thing you saw survives as often as the last.
Run the whole river ten thousand times over and count where the survivors came from. No arrival is favoured — each of the N positions levels to the same seven-in-N. That flat line is the fairness, drawn.
Intuition rebels: surely the newest arrivals dominate the cup? They do not. Each early item weathers ever-lengthening odds of eviction, and the two effects cancel to the decimal. Fairness is not designed into any single step — it falls out of the arithmetic.