From 3e3b00fe946a831b62ad212182e66c5742e0986e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bogumi=C5=82=20Kami=C5=84ski?= Date: Sun, 7 May 2017 23:25:29 +0200 Subject: [PATCH] Documentation of Efraimidis-Spirakis samplers (#254) --- docs/source/sampling.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/source/sampling.rst b/docs/source/sampling.rst index 963dc2b20b577..494bb2252895c 100644 --- a/docs/source/sampling.rst +++ b/docs/source/sampling.rst @@ -172,3 +172,27 @@ All following functions write results to ``x`` (pre-allocated) and return ``x``. It makes a copy of the weight vector at initialization, and sets the weight to zero when the corresponding sample is picked. This algorithm consumes ``O(k)`` random numbers, and has overall time complexity ``O(n k)``. + +.. function:: efraimidis_a_wsample_norep!([rng], a, wv, x) + + Implementation of weighted sampling without replacement using Efraimidis-Spirakis A algorithm. + + Reference: Efraimidis, P. S., Spirakis, P. G. *Weighted random sampling with a reservoir.* Information Processing Letters, 97 (5), 181-185, 2006. + + This algorithm takes ``O(n + k log k)`` processing time to draw ``k`` elements. It consumes ``n`` random numbers. + +.. function:: efraimidis_ares_wsample_norep!([rng], a, wv, x) + + Implementation of weighted sampling without replacement using Efraimidis-Spirakis A-Res algorithm. + + Reference: Efraimidis, P. S., Spirakis, P. G. *Weighted random sampling with a reservoir.* Information Processing Letters, 97 (5), 181-185, 2006. + + This algorithm takes ``O(k log(k) log(n / k))`` processing time to draw ``k`` elements. It consumes ``n`` random numbers. + +.. function:: efraimidis_aexpj_wsample_norep!([rng], a, wv, x) + + Implementation of weighted sampling without replacement using Efraimidis-Spirakis A-ExpJ algorithm. + + Reference: Efraimidis, P. S., Spirakis, P. G. *Weighted random sampling with a reservoir.* Information Processing Letters, 97 (5), 181-185, 2006. + + This algorithm takes ``O(k log(k) log(n / k))`` processing time to draw ``k`` elements. It consumes ``O(k log(n / k))`` random numbers.