Let $X_{1}, X_{2}, \ldots, X_{n}$ be IID random variables with mean $\mu$ and variance $\sigma^2$. Let $S_n=\sum_i^{n}X_i.$ Let $T\gg1$ and define $\tau=T-S_n$ where $n$ satisfies the following relation: $S_n<T<S_{n+1}$. What will be the distribution of $\tau$? I suspect that there exist a simple answer if we assume $T\gg1$ and we know the distribution of $X_i$ however I am not sure of the best approach to find it. I only am interested in the large $T$ regime, the idea would be that at time $T$ my system is in some thermal state. The following algorithm will generate such number $\tau$: - Initialise $t=0$. - While $t<T$: $t\to t+X_i$ - return $\tau = T-t$ Could I use large deviation principle to derive the distribution of $\tau$? Any suggestions are appreciated. Here is a sketch that illustrates the question: [![enter image description here][1]][1] [1]: https://i.sstatic.net/BCmBj.png