Vitter's reservoir sampling algorithm D: randomly selecting unique items
getkerf.wordpress.com
Vitter's reservoir sampling algorithm D: randomly selecting unique items
1–10 of 83 posts
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#2Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#3(I personally find Kevin's code very hard to follow)
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#4Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#5For practical purposes when list.length << total.lenght shouldn't that be good enough?
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#6Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#7So if N is really large and doesn't fit into main memory, how does one iterate over such large list in a reasonable amount of time? When I am taught algorithm my sample input is relatively small, from 10,000 elements to 1M integer numbers. Big deal. But I am not sure how to really think when N is really huge and whether we'd ever really have to deal with 10B integers in one pass. In that case, it's more likely I am paging through my database cursor... someone please shine light.
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#8> Reservoir sampling is a family of randomized algorithms for randomly choosing a sample of k items from a list S containing n items, where n is either a very large or unknown number. Typically n is large enough that the list doesn't fit into main memory. So if N is really large and doesn't fit into main memory, how does one iterate over such large list in a reasonable amount of time? When I am taught algorithm my sa…
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#9A SPN will generate a unique random permutation, from which you can draw your random list of unique items. With a little of post-ptocessing, you can generate random permutations of arbitrary size.
I have implemented it in matlab and python:
http://nl.mathworks.com/matlabcentral/fileexchange/36626-alg...
Re: Vitter's reservoir sampling algorithm D: randomly selecting unique items
#10Why cannot you just create random numbers and discard duplicates? For practical purposes when list.length << total.lenght shouldn't that be good enough?