From pburns at pburns.seanet.com  Sat Jun  2 09:57:22 2007
From: pburns at pburns.seanet.com (Patrick Burns)
Date: Sat, 02 Jun 2007 08:57:22 +0100
Subject: [Rd] Debug with set.seed()
In-Reply-To: <de14a0ea903e.46604672@usc.edu>
References: <de14a0ea903e.46604672@usc.edu>
Message-ID: <466122E2.5080102@pburns.seanet.com>

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



[Rd] Debug with set.seed()
Patrick Burns