From pgilbert at bank-banque-canada.ca  Wed Jul 20 16:42:07 2011
From: pgilbert at bank-banque-canada.ca (Paul Gilbert)
Date: Wed, 20 Jul 2011 14:42:07 +0000
Subject: [Rd] Randomness not due to seed
In-Reply-To: <1311081181602-3678082.post@n4.nabble.com>
References: <1311081181602-3678082.post@n4.nabble.com>
Message-ID: <6441154A9FF1CD4386AF4ABF141A056D265A90F2@WMEXOSCD2-N1.bocad.bank-banque-canada.ca>

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.

Paul

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


[Rd] Randomness not due to seed
Paul Gilbert