Reservoir Sampling

Use

It's useful when you have to k items out of a stream of n or infinite items, such that at the end all the items had an equal probability of being in k items.

Amazing Website:

Last updated