Skip to content
Back to formatted view

Raw Message

Message-ID: <19919.7666.165559.672775@max.nulle.part>
Date: 2011-05-15T00:27:30Z
From: Dirk Eddelbuettel
Subject: [Rcpp-devel] Rcpp equivalent of sample()?
In-Reply-To: <BANLkTimXV=VKt3BCi_A-ry4yaPM3RsRVqw@mail.gmail.com>

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

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