This function provides a very efficient way to pull an integer random sample sequence from an integer interval.
sample_seq(low, high, length)
An increasing numeric vector containing integers, the sample.
The algorithm runs in O(length)
expected time, even if
high-low
is big. It is much faster (but of course less general) than
the builtin sample
function of R.
Jeffrey Scott Vitter: An Efficient Algorithm for Sequential Random Sampling, ACM Transactions on Mathematical Software, 13/1, 58–67.
Other other:
convex_hull()
,
running_mean()
rs <- sample_seq(1, 100000000, 10)
rs
#> [1] 1854463 4841388 11085650 61479037 67193299 68060916 69854129 83816140
#> [9] 87879279 97113747