[Rcpp-commits] r3537 - in pkg/RcppSMC: . R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Mar 21 12:58:45 CET 2012


Author: adamj
Date: 2012-03-21 12:58:45 +0100 (Wed, 21 Mar 2012)
New Revision: 3537

Modified:
   pkg/RcppSMC/ChangeLog
   pkg/RcppSMC/R/pfLineartBS.R
Log:
Added dynamic range calculation for the online plotting function.


Modified: pkg/RcppSMC/ChangeLog
===================================================================
--- pkg/RcppSMC/ChangeLog	2012-03-20 20:54:57 UTC (rev 3536)
+++ pkg/RcppSMC/ChangeLog	2012-03-21 11:58:45 UTC (rev 3537)
@@ -1,3 +1,7 @@
+2012-03-21  Adam Johansen <a.m.johansen at warwick.ac.uk>
+	* R/pfLineartBS.R Added function to dynamically set the range of
+	the online plot.
+
 2012-03-19  Adam Johansen <a.m.johansen at warwick.ac.uk>
 	* R/simGaussian.R Added data-simulating function
 	* R/simLineart.R Idem

Modified: pkg/RcppSMC/R/pfLineartBS.R
===================================================================
--- pkg/RcppSMC/R/pfLineartBS.R	2012-03-20 20:54:57 UTC (rev 3536)
+++ pkg/RcppSMC/R/pfLineartBS.R	2012-03-21 11:58:45 UTC (rev 3537)
@@ -43,11 +43,38 @@
     invisible(dat)
 }
 
+pfLineartRange <- function(min,max)
+{
+   if(min > 0)
+   {
+	rmin = exp(floor(log(min)))
+   }
+   else if (min < 0) {
+   	rmin = -exp(ceiling(log(-min)))
+   }
+   else {
+   	rmin = 0
+   }
+
+   if(max > 0) 
+   {  
+	rmax = exp(ceiling(log(max)))
+   }
+   else if (max < 0){
+   	rmax = exp(floor(log(-max)))
+   }
+   else {
+   	rmax = 0;
+   }
+
+   invisible(c(rmin,rmax))
+}
+
 pfLineartBSOnlinePlot <- function(xm, ym) {
     # FIXME: xlim and ylim should be dependent on data, but of course
     # the online algorithm does not "know" the full dataset as it
     # works its way through
-    plot(xm, ym, xlim=c(-7,0), ylim=c(2,14))
+    plot(xm, ym, xlim = pfLineartRange(min(xm),max(xm)), ylim=pfLineartRange(min(xm),max(ym)))
     # FIXME sleep time should also be a variable
     Sys.sleep(0.05)
 }



More information about the Rcpp-commits mailing list