2 ms·
> sample k elements Not quite sure what you have in mind here, but you need reservoir sampling for this in order to make the selection uniformly random (which
by dooglius 10mo ago
> sample k elements
Not quite sure what you have in mind here, but you need reservoir sampling for this in order to make the selection uniformly random (which I assume is what's desired)
- shiandow 10mo agoYou can just use this algorithm but ignore everything after the first k elements. The algorithm still works if you don't store anything beyond the first k elements but just pretend they are there.