# Stopping time computations via martingales

I'm studying probability, and having trouble with the following problem (from this exam).

Suppose $X_j$ are i.i.d. random variables with $P(X_i=1) = P(X_i = -1) = 1/2$. Let $S_0=0$ and $S_n = X_1 + X_2, + \ldots + X_n$ (a simple symmetric random walk). Define a stopping time $$T := \inf\{n: S_n \notin (-a,b)\},$$ where $a,b \in \mathbb{N}$.

(1) Show $S_n^2-n$ is a martingale and compute $P(S_T = b)$.

(2) Find $ET$.

(3) Show that $S_n^4-6nS_n^2+3n^2+2n$ is a martingale and find $\text{var}(T)$.

(1) Showing that $S_n^2 -n$ is a martingale is simple. Also, $S_n$ is a martingale. Then since $T < \infty$ a.s., we get $$(-a)P(S_T = -a) + b(1-P(S_T=-a))$$$$= ES_T = E\lim S_{\min(T,n)} \overset{D.C.T.}{=} \lim ES_{\min(T,n)} = \lim ES_0 = 0.$$ Thus $P(S_T = -a) = b/(a+b)$ and $P(S_T = b) = a/(a+b)$.

(2) I want to say this:

$$E(S_T^2-T) = E\lim(S_{\min(T,n)}^2-\min(T,n)) \overset{?}{=} \lim E(S_{\min(T,n)}^2 - \min(T,n)) = \lim E(S_0^2 - 0) = 0,$$ but I don't know how to justify interchanging the limit and expectation there.

If this equality holds, then $ET = ES_T^2$, which I can compute.

(3) I can show that the given expression is a martingale. Again, if exchanging limits and expectations is justified, I get $$E(S_T^4-6TS_T^2+3T^2 +2T) = E(S_0^4-6\cdot 0 \cdot S_0 +3\cdot 0 +2 \cdot 0) = 0.$$ I can compute $ES_T^4$ and $E(2T)$, given part (2), but I don't know how to compute $ETS_T^2$.

Any suggestions for how to fill the gaps here? Thanks.

In (2), you know that $E(\min(T,n))=E(S^2_{\min(T,n)})$ for every $n$. When $n\to\infty$, $\min(T,n)\to T$ monotonically hence $E(\min(T,n))\to E(T)$ by Lebesgue monotone convergence theorem, and $S^2_{\min(T,n)}\to S_T^2$ almost surely and is dominated by $\max(a^2,b^2)$, hence $E(S^2_{\min(T,n)})\to E(S_T^2)$ by Lebesgue dominated convergence theorem. Thus $E(S_T^2)=E(T)$.
In (3), you forgot to mention the crucial hypothesis that $a=b$. Then $TS_T^2=a^2T$ almost surely hence $E(TS_T^2)=a^2E(T)$ and you are done.
(By the way, centering and using the invariance of the process by translation, one can modify the argument above to get the variance for every even $a+b$. If $a+b$ is odd, I guess one has to rely on the generating function of $T$. The usual recursion on the starting point of the random walk yields $E(s^T)=(r(s)^a+r(s)^b)/(1+r(s)^{a+b})$ with $r(s)=s^{-1}(1\pm\sqrt{1-s^2})$, from which one deduces the variance of $T$ and in fact the whole distribution of $T$.)