[Rd] algorithm reference for sample()

From: Vadim Ogranovich <vograno_at_evafunds.com>
Date: Fri 24 Sep 2004 - 10:48:45 EST


Hi,  

Don't know if it belongs to r-devel or r-help, but since I am planning to alter some of R's internal code I am sending it here.  

The existing implementation of the sample() function, when the optional 'prob' argument is given, is quite inefficient. The complexity is O(sampleSize * universeSize), see ProbSampleReplace() and ProbSampleNoReplace() in random.c. This makes the function impractical for the vector sizes I use. I want to re-code these functions and I "think" I can come up with a more efficient algorithm. However before I go and reinvent the wheel I wonder if there is a published description of an efficient sampling algorithm with user-specified probabilities?  

Thanks,
Vadim

        [[alternative HTML version deleted]]



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Sep 24 10:53:34 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:22 EST