real.samples <- 68
real.catches <- 7

events <- 5000        #1500 for 1 um, 5000 for 500 nm 
event_time <- 10      #endocytosis event in seconds
total_time <- 1800    #total time in seconds (30 min = 1800 s)
temporal <- total_time/event_time  
spatial <- 50         # 25 for 1 um in 25 um, 50 for 500 nm in 25 um 25/25

successes <- numeric(length=10000)

for (i in 1:10000) {
  if (i %% 100 == 0) message(i)
  one.round <- numeric(length=real.samples)
  for (j in 1:length(one.round)) {
    one.cell <- matrix(0, nrow=events, ncol=2)
    one.cell[,1] <- sample(1:temporal, nrow(one.cell), replace=TRUE) # random minutes
    one.cell[,2] <- sample(1:spatial, nrow(one.cell), replace=TRUE) # random locations
    for (k in 1:nrow(one.cell)) {
      if (one.cell[k, 1] == 1 & one.cell[k, 2] == 1) {
        one.round[j] <- 1
      }
    }  
  }
  successes[i] <- sum(one.round)
}

hist(successes,  main = paste("Vesicle size:",25/spatial,"um   #:",events,"\nTime per event:",event_time,"s  Total time:",total_time/60,"min"),xlab="Endocytic vesicles observed")
abline(v=7,col="red",lwd=2,lty=2)



