hi all a simple question i want to run simulations in r. i however want the experiments to be repeated at a later time with exactly the same numbers by other users. can i set the random number seed for rnorm in some way? e.g. is there some arguement that goes with rnorm? please supply an example regards Allan
look at ?set.seed, e.g.,
rnorm. <- function(seed, ...){
set.seed(seed)
rnorm(...)
}
#########
rnorm.(100, 1, 2)
I hope it helps.
Best,
Dimitris
----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven
Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm
----- Original Message -----
From: "Clark Allan" <Allan at stats.uct.ac.za>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, March 04, 2005 12:07 PM
Subject: [R] R: simulation
> hi all
>
> a simple question
>
> i want to run simulations in r. i however want the experiments to be
> repeated at a later time with exactly the same numbers by other
> users.
> can i set the random number seed for rnorm in some way?
>
> e.g. is there some arguement that goes with rnorm?
>
> please supply an example
>
> regards
> Allan
--------------------------------------------------------------------------------
> ______________________________________________
> R-help at 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
Clark Allan writes: > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way? > > e.g. is there some arguement that goes with rnorm? set.seed(79) ## replace 79 with another value if you don't like it rnorm(10) Hope this helps, Lukas -- Lukas Meier http://stat.ethz.ch/people/meier/ Seminar fuer Statistik phone: +41 44 632 35 04 ETH-Zentrum, LEO D6 fax: +41 44 632 12 28 CH-8092 Zurich, Switzerland
Hi thanx for the reply. i used your code and pasted it into R and ran it a few times. the output is below. what i want is to get the same output every time the program is run. is this possible? another question? x<-rnorm(100) y<-rnorm(100) is x and y independent?> rnorm(1)[1] 0.4251004> rnorm(1)[1] -0.2386471> rnorm(1)[1] 1.058483> rnorm(1)[1] 0.8864227> rnorm(1)[1] -0.619243> rnorm(1)[1] 2.206102> rnorm(1)[1] -0.2550270> rnorm(1)[1] -1.424495> rnorm(1)[1] -0.1443996> rnorm(1)[1] 0.2075383> rnorm(1)[1] 2.307978> rnorm(1)[1] 0.1058024 Dimitris Rizopoulos wrote:> > look at ?set.seed, e.g., > > rnorm. <- function(seed, ...){ > set.seed(seed) > rnorm(...) > } > ######### > rnorm.(100, 1, 2) > > I hope it helps. > > Best, > Dimitris > > ---- > Dimitris Rizopoulos > Ph.D. Student > Biostatistical Centre > School of Public Health > Catholic University of Leuven > > Address: Kapucijnenvoer 35, Leuven, Belgium > Tel: +32/16/336899 > Fax: +32/16/337015 > Web: http://www.med.kuleuven.ac.be/biostat/ > http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm > > ----- Original Message ----- > From: "Clark Allan" <Allan at stats.uct.ac.za> > To: <r-help at stat.math.ethz.ch> > Sent: Friday, March 04, 2005 12:07 PM > Subject: [R] R: simulation > > > hi all > > > > a simple question > > > > i want to run simulations in r. i however want the experiments to be > > repeated at a later time with exactly the same numbers by other > > users. > > can i set the random number seed for rnorm in some way? > > > > e.g. is there some arguement that goes with rnorm? > > > > please supply an example > > > > regards > > Allan > > -------------------------------------------------------------------------------- > > > ______________________________________________ > > R-help at 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
On 4 Mar 2005 at 13:07, Clark Allan wrote:> hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way?See ?set.seed It is called once before rnorm generator> set.seed(1) > rnorm(10)[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 - 0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884> set.seed(10) > rnorm(10)[1] 0.01874617 -0.18425254 -1.37133055 -0.59916772 0.29454513 0.38979430 -1.20807618 -0.36367602 -1.62667268 -0.25647839> set.seed(1) > rnorm(10)[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078 - 0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884>Cheers. Petr> > e.g. is there some arguement that goes with rnorm? > > please supply an example > > regards > AllanPetr Pikal petr.pikal at precheza.cz
On Fri, 04 Mar 2005 13:07:21 +0200 Clark Allan <Allan at STATS.uct.ac.za> wrote:> hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way?See ?.Random.seed Btw: it's on the help page for rnorm ... Detlef> > e.g. is there some arguement that goes with rnorm? > > please supply an example > > regards > Allan
Clark Allan wrote:> hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way? > > e.g. is there some arguement that goes with rnorm? > > please supply an example > > regards > Allan > > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at 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.htmlPlease read the docs and in particular: ?set.seed Uwe Ligges
See help("set.seed").
set.seed(1)
rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078
rnorm(5)
[1] -0.8204684 0.4874291 0.7383247 0.5757814 -0.3053884
set.seed(1)
rnorm(5)
[1] -0.6264538 0.1836433 -0.8356286 1.5952808 0.3295078
On Fri, 2005-03-04 at 13:07 +0200, Clark Allan wrote:> hi all
>
> a simple question
>
> i want to run simulations in r. i however want the experiments to be
> repeated at a later time with exactly the same numbers by other users.
> can i set the random number seed for rnorm in some way?
>
> e.g. is there some arguement that goes with rnorm?
>
> please supply an example
>
> regards
> Allan
> ______________________________________________ R-help at 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
?set.seed On Fri, 4 Mar 2005, Clark Allan wrote:> hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way? > > e.g. is there some arguement that goes with rnorm? > > please supply an example > > regards > Allan*********************************************************************** Christian Hennig Fachbereich Mathematik-SPST/ZMS, Universitaet Hamburg hennig at math.uni-hamburg.de, http://www.math.uni-hamburg.de/home/hennig/>From 1 April 2005: Department of Statistical Science, UCL, London####################################################################### ich empfehle www.boag-online.de
See ?set.seed. Andy> From: Clark Allan > > hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way? > > e.g. is there some arguement that goes with rnorm? > > please supply an example > > regards > Allan >
Clark Allan <Allan at STATS.uct.ac.za> writes:> hi all > > a simple question > > i want to run simulations in r. i however want the experiments to be > repeated at a later time with exactly the same numbers by other users. > can i set the random number seed for rnorm in some way? > > e.g. is there some arguement that goes with rnorm? > > please supply an exampleDo read the help page for rnorm, in particular the "See Also" section.> regards > Allan______________________________________________ > R-help at 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-- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
The help page for "rnorm" says "See Also: ...
'.Random.seed'
...", and the help page for ".Random.seed" says, "
'set.seed' is the
recommended way to specify seeds."
hope this helps.
spencer graves
Clark Allan wrote:
>hi all
>
>a simple question
>
>i want to run simulations in r. i however want the experiments to be
>repeated at a later time with exactly the same numbers by other users.
>can i set the random number seed for rnorm in some way?
>
>e.g. is there some arguement that goes with rnorm?
>
>please supply an example
>
>regards
>Allan
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help at 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
>