Andrei Alexandrescu <seewebsiteforem...@erdani.org> wrote:

Having a reservoir sample available would be nice. I'd be thrilled if you coded up a reservoirSample(r, n) function for addition to std.random.

Done. No comments or unittests yet, though.

randomSampleRange( R, num ) takes num samples from an input range, and
keeps a reservoir that is updated as you traverse the range (lazy, if you
wish).

randomSample( R, num ) takes num samples from all over a range (eager).

--
Simen

Attachment: RandomSample.d
Description: Binary data

Reply via email to