random generation with arrival rate for fixed time

Hi,

I'm sorry but I don't think I can help you because I still don't understand it. I present below a final idea of what I think you want, but if this is not what you are looking for, I suggest you create a reprex and hopefully someone else can figure it out. A reprex consists of the minimal code and data needed to recreate the issue/question you're having. You can find instructions how to build and share one here:

library(lubridate)

#Pick the starting conditions
sDate = "2020-11-20"
sTime = "14:30:00"
intervalMin = 120
nTimestamps = 10

#Generate the random timestamps
randomTimeStamps = as.POSIXct(paste(sDate, sTime)) + 
  seconds(runif(nTimestamps)*120*60)

sort(randomTimeStamps)
#>  [1] "2020-11-20 14:31:35 EST" "2020-11-20 14:35:11 EST"
#>  [3] "2020-11-20 14:48:33 EST" "2020-11-20 14:49:36 EST"
#>  [5] "2020-11-20 14:57:45 EST" "2020-11-20 15:08:26 EST"
#>  [7] "2020-11-20 15:23:44 EST" "2020-11-20 15:47:57 EST"
#>  [9] "2020-11-20 15:48:02 EST" "2020-11-20 16:26:12 EST"

Created on 2020-11-20 by the reprex package (v0.3.0)

Good luck,
PJ

1 Like