From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.ac.be>

Date: Fri 04 Mar 2005 - 23:32:37 EST

> #########

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

Dimitris Rizopoulos

Ph.D. Student

Biostatistical Centre

School of Public Health

Catholic University of Leuven

> 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?

> [1] 0.4251004

> [1] -0.2386471

> [1] 1.058483

> [1] 0.8864227

> [1] -0.619243

> [1] 2.206102

> [1] -0.2550270

> [1] -1.424495

> [1] -0.1443996

> [1] 0.2075383

> [1] 2.307978

> [1] 0.1058024

> Dimitris Rizopoulos wrote:

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Mar 05 01:27:59 2005

Date: Fri 04 Mar 2005 - 23:32:37 EST

are you sure you tried the function I gave you? There is a "." that you might have missed. When I try it I get this:

> rnorm. <- function(seed, ...){

+ set.seed(seed) + rnorm(...) + }

> #########

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

> rnorm.(1, 1)

[1] -0.6264538

Observe that the first argument is the seed, `...' is used to pass arguments to `rnorm()'!

x <- rnorm(100)

y <- rnorm(100)

are independent, however,

x <- rnorm.(1, 100)

y <- rnorm.(1, 100)

will be exactly the same.

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@STATS.uct.ac.za> To: "Dimitris Rizopoulos" <dimitris.rizopoulos@med.kuleuven.ac.be>; <r-help@stat.math.ethz.ch> Sent: Friday, March 04, 2005 1:21 PM Subject: Re: [R] R: simulation

*> Hi
*

>

> thanx for the reply.

>

> i used your code and pasted it into R and ran it a few times. the

>

> another question?

>

> x<-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@stats.uct.ac.za> >> To: <r-help@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@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 ______________________________________________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 Sat Mar 05 01:27:59 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:30:40 EST
*