I have blogged about weighted sampling before. There I found that the stochastic acceptance method suggested by Lipowski and Lipowska (2012) (also at https://arxiv.org/abs/1109.3627) is very promising:
// [[Rcpp::depends(dqrng,BH,sitmo)]]
#include &…