Suppose $\tau_1, \tau_2, \tau_3$ are arrival times and all follow an exponential distribution with parameter $\lambda_1, \lambda_2, \lambda_3$, respectively.
I fail in deriving the probability of the event $\tau_2 < \tau_1 < \tau_2 + \tau_3$ (intuitively: the "clock" of event 1 and 2 start at the same time, event 3 occurs only after event 2 was triggered).
My current approach looks as follows:
$$ P\left(\tau_2 < \tau_1 < \tau_2 + \tau_3\right) = P\left(0 < \tau_1 - \tau_2 < \tau_3\right)$$
Therefore, I am interested in the probability that $z:= \tau_1 - \tau_2$ is less than $\tau_3$. The pdf of the difference of two exponentially distributed random variables is given, for instance, here:
$$ P(z\leq \tau) = 1 - \frac{\lambda_2 e^{-\lambda_1 t}}{\lambda_1+\lambda_2}.$$
This yields
$$P\left(\tau_2 < \tau_1 < \tau_2 + \tau_3\right) = \int\limits_0^\infty P(z\leq \tau_3)\lambda_3\exp(-\lambda_3\tau_3)d\tau_3 \\ = 1 - \frac{\lambda_2\lambda_3}{(\lambda_1+\lambda_2)(\lambda_1+\lambda_3)}$$
However, simple simulations show me that something is wrong here..
l1 <- 1
l2 <- 4
la <- 40
s1 <- rexp(1000,l1)
s2 <- rexp(1000,l2)
s3 <- rexp(1000,l3)
mean(s2 < s1 & s1 < s2+s3)
0.01952
1-l2*l3/((l1+l2)*(l1+l3))
0.2195122
Do I miss something here?
Edit: The mistake was as follows: $P\left(0 < \tau_1 - \tau_2 < \tau_3\right) = P\left(\tau_1 - \tau_2 < \tau_3\right) - P\left(\tau_1 - \tau_2 < 0\right)$ because $\tau_1 - \tau_2$ can also take negative values. In that case I get
$$P\left(\tau_2 < \tau_1 < \tau_2 + \tau_3\right) = \int\limits_0^\infty (P(z\leq \tau_3) - P(z\leq 0))\lambda_3\exp(-\lambda_3\tau_3)d\tau_3 \\ = \frac{\lambda_2}{\lambda_1+\lambda_2}\left(1-\frac{\lambda_3}{\lambda_1+\lambda_3}\right)$$ which also yields the "correct" result for the simulation above:
l2/(l1+l2)*(1-la/(l1+la))
0.0195122