Hello,

Inline.

Em 01-01-2014 22:12, Chee Chen escreveu:
Dear All,

I would like to ask for your help on "reproducibility of random sampling with 
replacement". For example, one re-samples the rows with replacement of a residual 
matrix and uses the new residual matrix thus obtained to produce a statistic ; repeat 
this for a certain number of times.

My questions:  will the above produce ever be reproducible by setting a seed?

Yes.

Namely, Given the same residual matrix, Ted applies the above process and so does Jack, will they get the same results by setting a seed?

My attempt: setting seed does not freeze the command "sample" from  getting 
different samples,

Yes it does, you are simply not setting the seed before the first for loop.

Rui Barradas
 as from the codes:
====
x= 1:20
S = matrix(0,5,20)
for (i in 1:5) {
   S[i,] = sample(x, replace=FALSE)
}

set.seed(123)

T = matrix(0,5,20)
for (i in 1:5) {
   T[i,] = sample(x, replace=FALSE)
}
sum(S==T)
===

I would appreciate any comments and/or suggestions on this.
Regards,
Chee

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to