Two-event probability in a stochastic SIR model (source code)

= Two-event probability in a stochastic SIR model

With one initial infectious individual, two events require an infection as the first event. If it occurs at time $s$, its density is $\beta N e^{-(\beta N+\gamma)s}$ and the next total event rate is $2\beta(N-1)+2\gamma$. Integrating this density times the chance of another event before a fixed horizon gives the two-event probability.