[R] Simulation
Rolf Turner
r.turner at auckland.ac.nz
Thu May 14 00:26:38 CEST 2009
On 14/05/2009, at 10:04 AM, Carl Witthoft wrote:
> So far nobody seems to have warned the OP about seeding.
>
> Presumably Debbie wants 1000 different sets of samples, but as we all
> know there are ways to get the same sequence (initial seed) every
> time.
> If there's a starting seed for one of the "generate a single giant
> matrix" methods proposed, the whole matrix will be the same for a
> given
> seed.
> If rnorm is called 1000 times (hopefully w/ different random (oops)
> seeds), the entire set of samples will be different.
>
> and so on.
I really don't get this. The OP wanted 1000 independent samples,
each of size 100. Whether she does
set.seed(42)
M <- matrix(rnorm(100*1000),nrow=1000) # Each row is a sample.
or
L <- list()
set.seed(42)
for(i in 1:1000) L[[i]] <- rnorm(100) # Each list entry is a sample.
she gets this, i.e. the desired result. Setting a seed serves to make
the results reproducible. This works via either approach. Making
results
reproducible in this manner is advisable, but seed-setting is nothing
that the OP
needs to be *warned* about.
cheers,
Rolf Turner
######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
More information about the R-help
mailing list