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

Dirk Eddelbuettel edd at debian.org
Sun May 15 02:27:30 CEST 2011

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.


Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.com

More information about the Rcpp-devel mailing list