# Poisson process: how long until we observe two events separated by at least a specified amount of time?

The time between events in a Poisson process is described by the pdf $f(t; T_0)=\frac{1}{T_0}e^{-t/T_0}$.

I'm interested in estimating how long we would have to observe this process before we see two events separated by at least a specified time $T_{min}$. In other words, how long do I need to observe the process before I see an event, while not having seen an event in the previous time $T_{min}$?

Concrete example: the time between buses arriving at a stop is described by an exponential distribution with mean 10 minutes. How long do I have to wait at the bus stop before I see a bus, while not having seen a bus in the past 5 minutes?

This answer requires solving three subproblems:

1. How many bus arrivals $N$ do I expect to suffer through before experiencing a time between bus arrivals $> T_{min}$?

2. How long is the expected wait between buses $\mathbb{E}T_s$ given that $T_s \leq T_{min}$?

3. How long is the expected wait between two consecutive buses $\mathbb{E}T_l$ given that $T_l > T_{min}$?

The final answer is equal to $\mathbb{E}N \mathbb{E}T_s + \mathbb{E}T_l$, or perhaps just $\mathbb{E}N \mathbb{E}T_s$ if the time spent in the last interval isn't counted.

The answer to 3 is quite easy, thanks to the Exponential / Poisson assumption. The memoryless property of the Exponential distribution implies that $\mathbb{E}T_l = T_{min} + T_0$.

The answer to 2 is a little more involved; we have to find the expected value of the appropriate conditional random variate:

$$\frac{\int_0^{T_{\min}}xe^{-x/T_0}\text{d}x}{T_0(1-e^{-T_{min}/T_0})}$$

which, using integration by parts, solves to:

$$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}$$

As @Moormanly has observed, $N$ is distributed Geometric, in this case with parameter $p = \exp\{-T_{min}/T_0\}$. The expected value of a Geometric$(p)$ distribution is $(1-p)/p$, so, substituting and writing the full equation out, we get:

$$\left(\frac{1-e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}\right)\left(\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{1-e^{-T_{min}/T_0}}\right)+T_{min}+T_0$$

where the last two terms are optional depending upon the exact nature of the problem being solved. Making the obvious cancellation leads to:

$$\frac{T_0 - (T_0+T_{min})e^{-T_{min}/T_0}}{e^{-T_{min}/T_0}}+T_{min}+T_0$$

and some further algebra gets us to:

$$\frac{T_0}{e^{-T_{min}/T_0}}$$

Checking our results via simulation on your sample problem comes next. $T_0 = 10$ and $T_{min}=5$ gives us a calculated result of 16.483. Our simulation code:

res <- rep(0,10000)
for (i in 1:length(res)) {
res[i] <- x <- rexp(1,1/10)
while (x < 5) {
x <- rexp(1,1/10)
res[i] <- res[i] + x
}
}

c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res))))


reports the simulated mean and the associated t-statistic for testing whether or not it is equal to the calculated value. The results are:

> c(mean(res), (mean(res)-10/exp(-0.5))/(sd(res)/sqrt(length(res))))
[1] 16.5793553  0.8998745


which would seem to confirm that we haven't messed up our algebra anywhere.

Think first about the number of events you expect to observe, think next about the amount of time it will take to observe those events.

Letting $N$ be the number of events before an inter-arrival time of at least $T_{min}$, see that $N$ is geometric with parameter $p=P(T_i>T_{min})$. Now let $T$ be the amount of time taken to observe these events. Expanding using total expectation: $$E[T]\\=\sum_{n=1}^\infty P(N=n) E[T|N=n]\\=\sum_{n=1}^\infty P(N=n) \bigg((n-1)E[T_i|T_i<T_{min}]+E[T_i|T_i \ge T_{min}]\bigg)$$