From noreply at r-forge.r-project.org Thu Oct 17 19:58:45 2013 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Thu, 17 Oct 2013 19:58:45 +0200 (CEST) Subject: [Gsdesign-commits] r361 - in pkg/gsDesign: . R man Message-ID: <20131017175845.D38F618419D@r-forge.r-project.org> Author: keaven Date: 2013-10-17 19:58:45 +0200 (Thu, 17 Oct 2013) New Revision: 361 Added: pkg/gsDesign/R/.Rhistory pkg/gsDesign/man/.Rhistory Removed: pkg/gsDesign/tex/ Log: Deleted tex directory Added: pkg/gsDesign/R/.Rhistory =================================================================== Added: pkg/gsDesign/man/.Rhistory =================================================================== --- pkg/gsDesign/man/.Rhistory (rev 0) +++ pkg/gsDesign/man/.Rhistory 2013-10-17 17:58:45 UTC (rev 361) @@ -0,0 +1,29 @@ +# intervals should contain lengths of piecewise exponential time periods +rpwexp <- function(n,rate=1,intervals=NULL,cumulative=FALSE){ +if(is.null(intervals)){ +if (cumulative){return(cumsum(rexp(n,rate[1])))}else +return(rexp(n,rate[1]))} +k <- length(rate) +if (length(intervals) < k-1) stop("length(intervals) must be at least length(rate) - 1") +tx <- 0 +j <- 1 +times <- array(0,n) +timex <- cumsum(intervals) +indx <- array(TRUE,n) +for(i in 1:k){ +nindx <- sum(indx) +if (nindx==0) break +increment <- rexp(nindx,rate[i]) +if (cumulative) times[indx] <- tx + cumsum(increment) +else times[indx] <- tx + increment +if (i timex[i]) +} +} +return(times) +} +x <- rpwexp(10000, rate = c(1, 3, 10), intervals = c(.5,.5)) +plot(sort(x),(10000:1)/10001,log="y") +x <- rpwexp(10000, rate = c(5, 15, 30), intervals = c(100,200), cumulative=TRUE) +plot(x,1:10000)