Re: [Rd] Debug with set.seed()

From: Patrick Burns <pburns_at_pburns.seanet.com>
Date: Sat, 02 Jun 2007 08:57:22 +0100

I think you will find that 'set.seed' does give you the same random state each time. That you don't get the same result each time implies a bug in your code. Looking for uninitialized variables would probably be a good start. Using valgrind under Linux would most likely find the error quickly.

Also, using '<<-' is generally a bad idea.

Patrick Burns
patrick_at_burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

Tong Wang wrote:

>HI, all
> I am debugging an R code with dynamically loaded function in it. It seems set.seed(n) does not give me the same
>random draws every time. Could somebody tell me what I should do to get the same outcome verytime ?
> I am not sure what infomation is relevent to this question , the following is a really scatchy description of the code I wrote.I am using the R-2.4.1 built under Cygwin. OS is WinXP.
>
>Thanks a lot for any help.
>
> Myfunction<-function(...) {
> .......
> drawsomething<-function(){ out<- .C( "drawit"...........)
> var <<- out$var # assign the outputs}
> .......
> for( i in 1 : iter) { .........
> drawsomething()
> .......... }
>
> reture( var.stor ) #return stored result
>}
>
>______________________________________________
>R-devel_at_r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
>



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 02 Jun 2007 - 08:00:07 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 Mon 04 Jun 2007 - 10:34:34 GMT.

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