[R] sample from very large distribution

Charles C. Berry cberry at tajo.ucsd.edu
Thu Sep 30 01:43:27 CEST 2010


On Thu, 30 Sep 2010, Matthew Finkbeiner wrote:

> I don't have enough RAM for this problem, so I need a work around.  This is
> what I want to do:
>
> y<- sample(2^32, 100000, replace=FALSE)
>

y <- trunc(runif( 100000, 1, 2^32+1))
while( any( dup.y <-duplicated(y) ) ) y[dup.y] <-
 		trunc(runif( sum(dup.y), 1, 2^32+1))

HTH,

Chuck

> but my machine won't let me do that.  so I now do this:
>
> x<- seq(1,2^32, by=100)
> y<- sample(x, 100000, replace=FALSE)
>
> this works fine, but by selecting every 100th item, it introduces a
> systematicity that may be problematic.
>
> I've tried this:
> x<- seq(1,2^32, by=sample(1:200, 1))
>
> but that yields some unpredictable behavior
>
> so, any suggestions?
>
> Thank you kindly,
>
> Matthew
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901



More information about the R-help mailing list