[Rd] Randomness not due to seed

Paul Gilbert pgilbert at bank-banque-canada.ca
Wed Jul 20 16:42:07 CEST 2011

It does not look like your calculation is using the random number generator, so the other responses are probably more to the point.  

However, beware that setting the seed is not enough to guarantee the same random numbers. You need to also make sure you are using the same uniform RNG and any other generators you use, such as the normal generator. R has a large selection of possibilities. Your start up settings could change the default behaviour. Also, relying on the default will be a bit risky if you are interested in reproducible calculations, because the R default could change in the future (as it has in the past, and as has the Splus generator in the past).

If the RNG is important for your reproducible calculations then you might want to look at the examples and tests in the setRNG package.


> -----Original Message-----
> From: r-devel-bounces at r-project.org [mailto:r-devel-bounces at r-
> project.org] On Behalf Of jeroen00ms
> Sent: July 19, 2011 9:13 AM
> To: r-devel at r-project.org
> Subject: [Rd] Randomness not due to seed
> I am working on a reproducible computing platform for which I would
> like to
> be able to _exactly_ reproduce an R object. However, I am experiencing
> unexpected randomness in some calculations. I have a hard time finding
> out
> exactly how it occurs. The code below illustrates the issue.
> mylm1 <- lm(dist~speed, data=cars);
> mylm2 <- lm(dist~speed, data=cars);
> identical(mylm1, mylm2); #TRUE
> makelm <- function(){
> 	return(lm(dist~speed, data=cars));
> }
> mylm1 <- makelm();
> mylm2 <- makelm();
> identical(mylm1, mylm2); #FALSE
> When inspecting both objects there seem to be some rounding
> differences.
> Setting a seed does not make a difference. Is there any way I can
> remove
> this randomness and exactly reproduce the object every time?
> --
> View this message in context: http://r.789695.n4.nabble.com/Randomness-
> not-due-to-seed-tp3678082p3678082.html
> Sent from the R devel mailing list archive at Nabble.com.
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

La version française suit le texte anglais.


This email may contain privileged and/or confidential information, and the Bank of
Canada does not waive any related rights. Any distribution, use, or copying of this
email or the information it contains by other than the intended recipient is
unauthorized. If you received this email in error please delete it immediately from
your system and notify the sender promptly by email that you have done so. 


Le présent courriel peut contenir de l'information privilégiée ou confidentielle.
La Banque du Canada ne renonce pas aux droits qui s'y rapportent. Toute diffusion,
utilisation ou copie de ce courriel ou des renseignements qu'il contient par une
personne autre que le ou les destinataires désignés est interdite. Si vous recevez
ce courriel par erreur, veuillez le supprimer immédiatement et envoyer sans délai à
l'expéditeur un message électronique pour l'aviser que vous avez éliminé de votre
ordinateur toute copie du courriel reçu.

More information about the R-devel mailing list