Skip to content
Prev 2284 / 10988 Next

[Rcpp-devel] Rcpp equivalent of sample()?

On 14 May 2011 at 16:33, Douglas Bates wrote:
| You can check what is done in R itself in the R sources but I imagine that it
| uses a uniform random variate converted to an integer through the cumulative
| probabilities. The good news is that it is easy to create the cumulative
| weights with the std::accumulate function.

Good point. I just looked at src/main/random.c in the R sources, and the main
worker functions are once again defined as hidden.  Sigh.  May make sense to
'port' this as helper functions for Rcpp::IntegerVector.

Dirk