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@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.

Reply via email to