[R] same random numbers in different sessions

jim holtman jholtman at gmail.com
Sun Oct 10 01:16:12 CEST 2010


You need to set the set.seed yourself.  There are some simulation
where I do want the same numbers generated and can use the set.seed to
set it to a know value.  If you want something random each time, then
use the time of day in the call to set.seed.

On Sat, Oct 9, 2010 at 5:14 PM, Liviu Andronic <landronimirc at gmail.com> wrote:
> Dear all
> I'm using Xubuntu Lucid and I keep getting the same random numbers
> whenever I start a new session of R. For example, I keep getting
>> sample(1:1000, 1)
> [1] 87
>
> or
>> rnorm(1:10)
>  [1] -1.3618103  0.4241701  1.0720076  0.2208145 -0.5375314 -0.4846588
>  [7]  0.7576768  0.6527407 -0.6868786  0.8718527
>
> I expected that some set.seed() instruction woudl be present in a
> config file in
> /usr/lib/R/etc/
>
> but after grepping the only reference came out in Rprofile.site and it
> was commented out:
> # set.seed(1234)
>
> What else could be causing this? Regards
> Liviu
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> x86_64-pc-linux-gnu
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] fortunes_1.4-0 sos_1.3-0      brew_1.0-3     IPSUR_1.1
>
>
> --
> Do you know how to read?
> http://www.alienetworks.com/srtest.cfm
> http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
> Do you know how to write?
> http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail
>
> ______________________________________________
> R-help at 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list