Taka Matzmoto
2006-Feb-08 03:21 UTC
[R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice
Hi R users This looks a simple question Is there any difference between between rnorm(1000,0,1) and running rnorm(500,0,1) twice in terms of outcome ? TM
Romain Francois
2006-Feb-08 08:51 UTC
[R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice
Le 08.02.2006 04:21, Taka Matzmoto a ??crit :>Hi R users > >This looks a simple question > >Is there any difference between between rnorm(1000,0,1) and running >rnorm(500,0,1) twice in terms of outcome ? > >TM > >Not here : R> set.seed(1) R> x <- rnorm(1000, 0, 1) R> set.seed(1) R> y <- rnorm(500, 0, 1) R> z <- rnorm(500, 0, 1) R> all(x == c(y,z)) [1] TRUE Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques mixmod 1.7 is released : http://www-math.univ-fcomte.fr/mixmod/index.php +---------------------------------------------------------------+ | Romain FRANCOIS - http://francoisromain.free.fr | | Doctorant INRIA Futurs / EDF | +---------------------------------------------------------------+
Philippe Grosjean
2006-Feb-08 09:08 UTC
[R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice
Romain Francois wrote:> Le 08.02.2006 04:21, Taka Matzmoto a ??crit : > > >>Hi R users >> >>This looks a simple question >> >>Is there any difference between between rnorm(1000,0,1) and running >>rnorm(500,0,1) twice in terms of outcome ? >> >>TM >> >> > > Not here : > > R> set.seed(1) > R> x <- rnorm(1000, 0, 1) > R> set.seed(1) > R> y <- rnorm(500, 0, 1) > R> z <- rnorm(500, 0, 1) > R> all(x == c(y,z)) > [1] TRUE > > RomainIndeed! The pseudo-random number generator is initialized at the same state, and thus, returns the same 1000 pseudo-random numbers in both cases. So, no differences. Best, Philippe Grosjean
Bjørn-Helge Mevik
2006-Feb-08 09:53 UTC
[R] difference between rnorm(1000, 0, 1) and running rnorm(500, 0, 1) twice
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. :-) -- Bj??rn-Helge Mevik