2 ms·
Reservoir sampling or Algorithm R. It allows you to randomly choose a sample of k items (with equal probability) from an "infinite" stream of items. At first it
by unsupported 8y ago
Reservoir sampling or Algorithm R. It allows you to randomly choose a sample of k items (with equal probability) from an "infinite" stream of items.
At first it sounds impossible, but the solution and proof are extremely simple and elegant.