Re: [R] How do you force runif to return non-duplicate results eg runif(0, 1, n=10)? thanks

About this list Date view Thread view Subject view Author view Attachment view

From: Gabor Grothendieck (ggrothendieck@myway.com)
Date: Tue 18 May 2004 - 22:14:26 EST


Message-id: <loom.20040518T140430-692@post.gmane.org>

Briggs, Meredith M <Meredith.Briggs <at> team.telstra.com> writes:

How do you force runif to return non-duplicate results
eg runif(0, 1, n=10)? thanks

On my Windows XP machine I find that the first 100,000 random numbers
starting from seed 11 are unique even to machine precision. Is that enough?

R> set.seed(11); length(unique(runif(100000)))
[1] 100000

If you need 100 numbers that are unique to two decimal places, say,
you can do this:

(sample(100, 100, rep=F)-1)/100

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:11 EST