Keep a fair sample of k items from a stream of unknown length: item i gets in with probability k/i.
This interactive visualization needs JavaScript.