wrswoR-package: Faster weighted sampling without replacement

Description Details Author(s) References Examples

Description

R's default sampling without replacement using base::sample.int() seems to require quadratic run time, e.g., when using weights drawn from a uniform distribution. For large sample sizes, this is too slow. This package contains several alternative implementations.

Details

Implementations are adapted from http://stackoverflow.com/q/15113650/946850.

Author(s)

Kirill Müller

References

Efraimidis, Pavlos S., and Paul G. Spirakis. "Weighted random sampling with a reservoir." Information Processing Letters 97, no. 5 (2006): 181-185.

Wong, Chak-Kuen, and Malcolm C. Easton. "An efficient method for weighted sampling without replacement." SIAM Journal on Computing 9, no. 1 (1980): 111-113.

Examples

1
sample_int_rej(100, 50, 1:100)

wrswoR documentation built on Feb. 3, 2018, 1:04 a.m.