Re: [R] Random number generation

From: Stephan Kolassa <Stephan.Kolassa_at_gmx.de>
Date: Sun, 11 May 2008 09:31:42 +0200

Dennis,

I assume that there is a set.seed() somewhere in your script, possibly in something you source()d (hopefully not in anything library()d).

Have you tried successively removing/commenting parts of the script before the sample() command until the problem goes away? That way you should be able to pinpoint the offending script command.

Good luck,
Stephan

Dennis Fisher schrieb:
> Colleagues,
>
> I have encountered behavior of random number generation that eludes me.
>
> I generate a random integer in a particular range using the following
> code:
> sample(1000:9999, size=1)
>
> This code exists within a script that starts with the command:
> remove(list=ls())
>
> Each time that I run the script, it yields the same random number:
> 6420.
>
> I thought that the problem might result from deleting the random
> seed. However, list=ls() does not include .RandomSeed.
>
> To my surprise, I can't replicate the problem with a 2-line script:
> remove(list-ls())
> sample(1000:9999, size=1)
>
> Also, the same problem occurs if I use runif instead of sample.
>
> Thoughts?
>
> Dennis
>
> Dennis Fisher MD
> P < (The "P Less Than" Company)
> Phone: 1-866-PLessThan (1-866-753-7784)
> Fax: 1-415-564-2220
> www.PLessThan.com
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>
>



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. Received on Sun 11 May 2008 - 07:43:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 11 May 2008 - 12:30:37 GMT.

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

list of date sections of archive