krlmlr / wrswoR

A package with different implementations of weighted random sampling without replacement in R
https://krlmlr.github.io/wrswoR
18 stars 2 forks source link

Precompute the partial sums for faster jumps. #8

Closed ruler501 closed 2 years ago

krlmlr commented 3 years ago

Thanks. The build fails, I suspect the code requires C++17? https://en.cppreference.com/w/cpp/algorithm/inclusive_scan

This is a clever trick, are you sure that the run time is faster? In contrast to naïve implementations, there is no nested loop in expj AFAICT.

If it's indeed faster, can you please add 3-5 lines of comments that explain this? How can we test that the new implementation works correctly?

krlmlr commented 2 years ago

Please submit a new PR if still relevant.