[R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice
Brian D Ripley
ripley at stats.ox.ac.uk
Wed Feb 8 14:30:54 CET 2006
On Wed, 8 Feb 2006, Duncan Murdoch wrote:
> On 2/8/2006 4:53 AM, Bjørn-Helge Mevik wrote:
> > Why don't you test it yourself?
> >
> > E.g.,
> >
> > set.seed(42)
> > bob1 <- rnorm(1000,0,1)
> > set.seed(42)
> > bob2 <- rnorm(500,0,1)
> > bob3 <- rnorm(500,0,1)
> > identical(bob1, c(bob2, bob3))
> >
> > I won't tell you the answer. :-)
>
> This isn't really something that can be proved by a test. Perhaps the
> current implementation makes those equal only because 500 is even, or
> divisible by 5, or whatever...
>
> I think the intention is that those should be equal, but in a quick
> search I've been unable to find a documented guarantee of that. So I
> would take a defensive stance and assume that there may be conditions
> where c(rnorm(m), rnorm(n)) is not equal to rnorm(m+n).
>
> If someone can point out the document I missed, I'd appreciate it.
It's various source files in R_HOME/src/main.
Barring bugs, they will be the same. As you know
R is free software and comes with ABSOLUTELY NO WARRANTY.
--
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
More information about the R-help
mailing list