public class TapeSampling<T>
extends java.lang.Object
Sampling algorithm that picks 'k' random samples from streaming input.
The algorithm would maintain 'k/N' probability to pick any of the item
where 'N' is the number of items seen currently.
While the input could be streaming, the algorithm requires N
to be known
before hand.
The algorithm produces random saamples without replacement and hence has O(1) extra
memory complexity
Implementation inspired from "JONES,T.G. A note on sampling a tape file"
(https://dl.acm.org/citation.cfm?id=368159)