Re: [R] set.seed

From: ronggui <ronggui.huang_at_gmail.com>
Date: Wed 14 Jun 2006 - 19:38:02 EST

set.seed is used to set the random number seed. When we use functions ,say runif, to generate random number ,we almost get different set of random number.
> runif(5)

[1] 0.2096388 0.3427873 0.5455948 0.7694844 0.4287647
> runif(5)

[1] 0.6864617 0.5218690 0.7965364 0.9030520 0.4324572

But in some cases,we want the results reproducible.so we use set.seed before generate the number.
>set.seed(100)
> runif(5)
[1] 0.30776611 0.25767250 0.55232243 0.05638315 0.46854928
> set.seed(100)
> runif(5)
[1] 0.30776611 0.25767250 0.55232243 0.05638315 0.46854928

So if you set the same random number seed before you generate the number,you get the same result.(That's why we call it pesudo-random number.)

As for what the i in set.seed(i) should be,I don't think it is a serious matter.

2006/6/14, Xiaohua Dai <ecoinformatics@gmail.com>:
> Hi R users,
>
> Sorry for a simple question:
> I found different people use different i in set.seed(i), are there any
> rules to choose an i or one can choose as he likes?
>
> Thanks
> Xiaohua
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
ٹ
Deparment of Sociology
Fudan University



______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Received on Wed Jun 14 19:42:26 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 14 Jun 2006 - 22:11:47 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.