Hi Xiaoxi,

Take a look at the following:

> set.seed(123)
> rnorm(10)
 [1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774  1.71506499
 [7]  0.46091621 -1.26506123 -0.68685285 -0.44566197
> rnorm(10)
 [1]  1.2240818  0.3598138  0.4007715  0.1106827 -0.5558411  1.7869131
 0.4978505
 [8] -1.9666172  0.7013559 -0.4727914
> set.seed(123)
> rnorm(10)
 [1] -0.56047565 -0.23017749  1.55870831  0.07050839  0.12928774  1.71506499
 [7]  0.46091621 -1.26506123 -0.68685285 -0.44566197

and check ?set.seed().

HTH,
Jorge


On Mon, Nov 8, 2010 at 3:57 PM, Xiaoxi Gao <> wrote:

>
> Hello R users,
> Here is my question about generating random sample. How to set the random
> seed to recreate the same random numbers?  For example, 10 random numbers is
> generated from N(0,1), then "runif(10)" is used.What if I want to get the
> same 10 random numbers when I run runif(10) again? Is it possible?I think
> .Random.seed should be used here.
> Thanks.
> Xiaoxi
>        [[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.
>

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

Reply via email to