[S] Summary: RE: Problems in generating Random Numbers

Smith, Stephen (SmithSJ@mar.dfo-mpo.gc.ca)
Mon, 01 Jun 1998 10:53:46 -0300


On the 25th of May I had reported a problem with using sample() to
conduct a simulation and having .Random.seed reset back to the same
number. Earlier Patrik OHagen had reported a similar problem with
cov.mve which was confirmed by Brian Ripley.

Thanks to Stephen Weller from Mathsoft for his quick assistance.

It appears that Patrik's and my problems had a similar basis:

cov.mve resets .Random.seed internally and therefore any simulation with
this function will run into problems. A fix to this problem requres
change to the code with an option to change the seed. The specific code
is:

class(ans) <- "mve"
attr(ans, "call") <- sys.call()
return(ans)
}
set.seed(4)
if(!missing(mutate.prob)) {
if(length(mutate.prob) != 4)
stop("mutate.prob must have length 4")
if(any(mutate.prob < 0))
stop("negative value in mutate.prob")
if(sum(mutate.prob[2:4]) > 1)
stop("sum of last 3 mutation probabilities
greater than 1")
}

In may case, I use jackknife() later on my code which defaults to seed=0
in its call statement:

> args(jackknife)
function(data, statistic, args.stat = NULL, seed = 0, group.size = 1,
assign.frame1 = F)

This feature can be by-passed by conducting the simulation with
something like seed=sample(1000,1) in the call statement.

Stephen Smith

---------------------------------------
Stephen J. Smith
Head, Molluscan Fisheries Section
Invertebrate Fisheries Division
Department of Fisheries and Oceans
P.O. Box 1006
Dartmouth, Nova Scotia
Canada B2Y 4A2

Street address for Couriers:
1 Challenger Drive

Voice: 902-426-3317
Fax: 902-426-1862
Note new email address.
Internet: Smithsj@mar.dfo-mpo.gc.ca

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news