# Residual time

In the theory of renewal processes, a part of the mathematical theory of probability, the residual time or the forward recurrence time is the time between any given time $t$ and the next epoch of the renewal process under consideration. In the context of random walks, it is also known as overshoot. Another way to phrase residual time is "how much more time is there to wait?".
The residual time is very important in most of the practical applications of renewal processes:
* In queueing theory, it determines the remaining time, that a newly arriving customer to a non-empty queue has to wait until being served.
* In wireless networking, it determines, for example, the remaining lifetime of a wireless link on arrival of a new packet.
* In dependability studies, it models the remaining lifetime of a component.
* etc.

## Formal definition

Consider a renewal process $\{N(t),t\geq 0\}$, with holding times $S_{i}$ and jump times (or renewal epochs) $J_{i}$, and $i\in \mathbb {N}$. The holding times $S_{i}$ are non-negative, independent, identically distributed random variables and the renewal process is defined as $N(t)=\sup\{n:J_{n}\leq t\}$. Then, to a given time $t$, there corresponds uniquely an $N(t)$, such that:
    $J_{N(t)}\leq t<J_{N(t)+1}.\,$
The residual time (or excess time) is given by the time $Y(t)$ from $t$ to the next renewal epoch.
    $Y(t)=J_{N(t)+1}-t.\,$

## Probability distribution of the residual time

Let the cumulative distribution function of the holding times $S_{i}$ be $F(t)=Pr[S_{i}\leq t]$ and recall that the renewal function of a process is $m(t)=\mathbb {E} [N(t)]$. Then, for a given time $t$, the cumulative distribution function of $Y(t)$ is calculated as:
    $\Phi (x,t)=\Pr[Y(t)\leq x]=F(t+x)-\int _{0}^{t}\left[1-F(t+x-y)\right]dm(y)$
Differentiating with respect to $x$, the probability density function can be written as
    $\phi (x,t)=f(t+x)+\int _{0}^{t}f(u+x)m'(t-u)du,$
where we have substituted $u=t-y.$ From elementary renewal theory, $m'(t)\rightarrow 1/\mu$ as $t\rightarrow \infty$, where $\mu$ is the mean of the distribution $F$. If we consider the limiting distribution as $t\rightarrow \infty$, assuming that $f(t)\rightarrow 0$ as $t\rightarrow \infty$, we have the limiting pdf as
    $\phi (x)={\frac {1}{\mu }}\int _{0}^{\infty }f(u+x)du={\frac {1}{\mu }}\int _{x}^{\infty }f(v)dv={\frac {1-F(x)}{\mu }}.$
Likewise, the cumulative distribution of the residual time is
    $\Phi (x)={\frac {1}{\mu }}\int _{0}^{x}[1-F(u)]du.$
For large $t$, the distribution is independent of $t$, making it a stationary distribution. An interesting fact is that the limiting distribution of forward recurrence time (or residual time) has the same form as the limiting distribution of the backward recurrence time (or age). This distribution is always J-shaped, with mode at zero.
The first two moments of this limiting distribution $\Phi$ are:
    $E[Y]={\frac {\mu _{2}}{2\mu }}={\frac {\mu ^{2}+\sigma ^{2}}{2\mu }},$
    $E[Y^{2}]={\frac {\mu _{3}}{3\mu }},$
where $\sigma ^{2}$ is the variance of $F$ and $\mu _{2}$ and $\mu _{3}$ are its second and third moments.

### Waiting time paradox

The fact that $E[Y]={\frac {\mu ^{2}+\sigma ^{2}}{2\mu }}>{\frac {\mu }{2}}$ (for $\sigma >0$) is also known variously as the waiting time paradox, inspection paradox, or the paradox of renewal theory. The paradox arises from the fact that the average waiting time until the next renewal, assuming that the reference time point $t$ is uniform randomly selected within the inter-renewal interval, is larger than the average inter-renewal interval ${\frac {\mu }{2}}$. The average waiting is $E[Y]={\frac {\mu }{2}}$ only when $\sigma ^{2}=0$, that is when the renewals are always punctual or deterministic.

### Special case: Markovian holding times

When the holding times $S_{i}$ are exponentially distributed with $F(t)=1-e^{-\lambda t}$, the residual times are also exponentially distributed. That is because $m(t)=\lambda t$ and:
    $\Pr[Y(t)\leq x]=\left[1-e^{-\lambda (t+x)}\right]-\int _{0}^{t}\left[1-1+e^{-\lambda (t+x-y)}\right]d(\lambda y)=1-e^{-\lambda x}.$
This is a known characteristic of the exponential distribution, i.e., its memoryless property. Intuitively, this means that it does not matter how long it has been since the last renewal epoch, the remaining time is still probabilistically the same as in the beginning of the holding time interval.

## Related notions

Renewal theory texts usually also define the spent time or the backward recurrence time (or the current lifetime) as $Z(t)=t-J_{N(t)}$. Its distribution can be calculated in a similar way to that of the residual time. Likewise, the total life time is the sum of backward recurrence time and forward recurrence time.