Re: [R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice

From: Peter Dalgaard <>
Date: Thu 09 Feb 2006 - 02:25:39 EST

Duncan Murdoch <> writes:

> 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.

I think it's a fair assumption that *uniform* random numbers have the property, since these are engines that produce a continuous stream of values, of which we select the next n and m values.

As long as the normal.kind (see ?RNGkind) is "Inversion", we can be sure that the property carries to rnorm, but it might not be the case for other methods. In particular the ones that generate normal variates in batches are suspect. However, empirically, I can't seem to provoke the effect with any of R's built-in generators. One *could* of course check the source code and see whether there is state information being kept between invokations...

   O__  ---- Peter Dalgaard             ุster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (                  FAX: (+45) 35327907

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Thu Feb 09 03:25:22 2006

This archive was generated by hypermail 2.1.8 : Fri 10 Feb 2006 - 21:35:42 EST