randomSample with unknown length
Simen kjaeraas
simen.kjaras at gmail.com
Wed Feb 2 07:40:42 PST 2011
Andrei Alexandrescu <SeeWebsiteForEmail at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RandomSample.d
Type: application/octet-stream
Size: 1837 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110202/b1b39468/attachment.obj>
More information about the Digitalmars-d
mailing list