4 ms·
Vitter's algorithm is for when you need to generate a random list of unique items with sequential reads. If you drop that requirement, you can just use a substi
by jdfr 11y ago
Vitter's algorithm is for when you need to generate a random list of unique items with sequential reads. If you drop that requirement, you can just use a substitution-permutation network: https://en.wikipedia.org/wiki/Substitution-permutation_network https://en.wikipedia.org/wiki/Substitution-permutation_netwo...
A 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-algorithmic-pseudo-random-permutations-for-large-sequences http://nl.mathworks.com/matlabcentral/fileexchange/36626-alg...
https://gist.github.com/jdfr/46633c630471494d67ae https://gist.github.com/jdfr/46633c630471494d67ae