Solution (source code)

= Solution

The future levels are independent of the observed maximum. Given $Y_n=z$, the first $k-1$ future levels must be at most $z$, and the $k$th must exceed $z$. Each non-overflow has <probability> $F(z)$ and an overflow has <probability> $1-F(z)$. Therefore
$$
\boxed{P(\tau=k\mid Y_n=z)=F(z)^{k-1}[1-F(z)],\qquad k\geq1.}
$$
This is a <geometric distribution> of parameter $1-F(z)$ when $F(z)<1$. Since $Y_n$ has a continuous distribution, conditioning on an exact value is understood via a <regular conditional distribution>, rather than division by $P(Y_n=z)=0$. The formula specifies its usual version. If $F(z)=1$ there is no possible overflow at that threshold, but such thresholds have <probability> zero for the random observed maximum.