Reservoir Sampling

The reservoir-sampling vocabulary is a way to take k samples with equal probability from all the objects shown to the sampler. This means that you do not have to know how many objects the sampler will eventually see, and that the probability will still be equivalent.

Create a sampler:
<reservoir-sampler> ( k -- sampler )

Show it samples:
reservoir-sample ( obj sampler -- )

Reservoir sampling without an object:
reservoir-sample-iteration ( iteration k obj sampled -- sampled' )