VTK
9.3.20240418
|
Generate a monotonic sequence of integers that randomly kk-sample a range without substitution. More...
#include <vtkReservoirSampler.h>
Generate a monotonic sequence of integers that randomly kk-sample a range without substitution.
Given a sequence of size nn, we wish to choose kk random values from the array. This class returns kk (or fewer, if nn < kk) indices in the range [0, nn-1[ that are ordered from smallest to largest.
The algorithm is an implementation of Kim-Hung Li's approach, known as "Algorithm L" and documented in the article "Reservoir-Sampling Algorithms of Time Complexity O(n(1+log(N/n)))". ACM Transactions on Mathematical Software. 20 (4): 481–493. doi:10.1145/198429.198435.