randomSample with unknown length
Magnus Lie Hetland
magnus at hetland.org
Wed Feb 2 12:06:44 PST 2011
On 2011-02-02 16:32:25 +0100, Andrei Alexandrescu said:
> randomSample is designed to subsample a large stream in constant space
> and without needing to scan the entire stream in order to output the
> first element.
Sure. I was just thinking that you could have a version for the cases
where there was no end in sight :)
> I used in in my dissertation where e.g. I had to select 100K samples
> from a stream of many millions.
Cool.
> 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.
Seems Simen beat me to it :)
--
Magnus Lie Hetland
http://hetland.org
More information about the Digitalmars-d
mailing list