Briggs, Meredith M
2004-May-18 01:06 UTC
[R] How do you force runif to return non-duplicate results eg runif(0, 1, n=10)? thanks
[This email is either empty or too large to be displayed at this time]
Prof Brian Ripley
2004-May-18 04:55 UTC
[R] How do you force runif to return non-duplicate results eg runif(0, 1, n=10)? thanks
On Tue, 18 May 2004, Briggs, Meredith M wrote: <nothing> runif by definition samples independently from U(0,1). So by defnition the results are not duplicated. It is possible due to finite computer representations that you would get duplicates to computer accuracy but the chance of that in sample size of 10 is about the chance of winning the UK lottery twice in a row, and much less plausible than a computer fault. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Gabor Grothendieck
2004-May-18 12:14 UTC
[R] How do you force runif to return non-duplicate results eg runif(0, 1, n=10)? thanks
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