R-beta: postscript in S

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Mon Apr 27 00:15:50 CEST 1998


helgito at hag.hi.is (Helgi Tomasson) writes:

> These innocent looking lines:
> 
> postscript(file="cusum1.ps",horizontal=T)
> nn <- 1:15698
> cumefri <- 0.948*(15698^0.5+2*nn/15698^0.5)
> cumeps <- cumsum(eps)
> cumedrif <- cumsum(epsdrif)
> plot(cumeps,ylim=range(cumeps),xlab="Observation number",
> ylab="cusum",type='l',lty=1)
> legend(1000,650,"no drift",lty=1,bty="n")
> par(new=T)
> plot(cumedrif,ylim=range(cumeps),xlab="",ylab="",type='l',lty=2)
> legend(1000,500,"drift",lty=2,bty="n")
> par(new=T)
> plot(cumefri,ylim=range(cumeps),xlab="",ylab="",type='l',lty=3)
> legend(1000,350,"95% limit",lty=3,bty="n")
> 
> generated 753155 Apr 25 19:57 cusum1.ps
> in R but
>   63586 Apr 25 20:50 cusum1.ps
> in S

There's something missing before we could actually run that (notably
"eps"). However stripping the ylim= bit from the last plot gives 
253438 bytes, so I'll believe you. 

You are drawing 16000 connected points and each line segment looks
like this:

369.36 263.95 l
369.40 263.98 l
369.45 264.01 l
369.49 264.04 l
369.53 264.06 l

14 bytes apiece, and 15698*14=219772, so that explains the order of
magnitude.

That kind of thing can be optimized in a number of ways. First of all,
you could use relative moves, roughly .04 in the x direction and .03
in the y direction in this case and set the units so that you'd get
small integer displacements. Then you might also note that some of the
moves are smaller than the device resolution (0.12 in these units on a
600 dpi printer) and drop them altogether. Squeezing it all into about
22000 bytes is still a bit extreme, I'd say.

R doesn't do this kind of optimisation. It could, if anyone wants to
contribute the code, but I don't think it is high on the agenda for
anyone on the core team. Beware that it requires a bit of caution, I'm
pretty sure than I've seen problems in (early) Splus where cumulative
distribution functions wouldn't end at 1.0, etc...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list