Optional Sampling
Stopping times
Example 1 (Gamblers ruin). Suppose a gambler plays a game at a casino. He bets a dollar, and with probability $1/2$ he gets 2 dollars (so wins $1$ dollar total), and with probability $1/2$ he gets nothing and loses his bet. When he runs out of money, he is ruined and leaves. The game is clearly fair. What is the probability he gets ruined? Turns out, he gets ruined with probability $1$, even though the game is fair. We study this in a little more generality below.
Definition 2 (Stopping time). We say a random variable $\tau$ is a stopping time if for all $n \in \N$, the event $\set{\tau = n} \in \mathcal F_n$.
Remark 3. It is often convenient to allow $\tau$ to also take on the value $\infty$; so instead of requiring $\tau \colon \Omega \to \N$, we allow $\tau \colon \Omega \to \N \cup \infty$. We say $\tau$ is a finite stopping time if $\tau < \infty$ almost surely.
Remark 4. Think of $\tau$ as the time a gambler decides to stop playing a game. The decision to stop playing at time $n$ has to be based on information available up to time $n$, and can not involve outcomes of the games at future times.
Problem 5. Let $\set{X_n}_{n \in \N}$ be an adapted process, and $\set{A_n}_{n \in \N}$ be a family of Borel subsets of $\R$. Show that $\tau = \min \set{ n \in \N \st X_n \in A_n}$ is a stopping time, however $\sigma = \max \set{ n \in \N \st X_n \in A_n }$ need not be. (Here, and subsequently we use the convention that $\min \emptyset = \infty$, and $\max \emptyset = 0$.)
Remark 6. Think of $X_n$ as the outcome of a game at time $n$ (or stock price). The first time $\set{X_n \in A_n}$ is exactly $\tau$, and the last time $\set{X_n \in A_n}$ is $\sigma$. The first time your condition $\set{X_n \in A_n}$ is met can be decided using only knowledge of events that have transpired, and so is a valid stopping time. The last time your condition $\set{X_n \in A_n}$ is met needs to inspect all future events so is not a valid stopping time.
Proposition 7.
- If $N \in \N$ is fixed, then $\tau = N$ is a stopping time.
- If $\sigma, \tau$ are stopping times, then so is $\sigma \varmin \tau$ and $\sigma \varmax \tau$.
Problem 8. Let $\set{\xi_n}_{n \in \N}$ be i.i.d. random variables with $\E \xi_1 = 0$ and $\P(\xi_1 = 0) < 1$. Let $N \in \N$, $X_0 \in \set{0, \dots, N}$ and define $X_{n+1} = X_n + \xi_n$. Consider the stopping time $\tau = \min \set{n \in \N \st X_n \not\in (0, N) }$. Show that $\E \tau < \infty$.
Hint. Let $p = \P(\xi_n \geq 1) > 0$, and show that for every $m \in \N$, $\P(\tau > m N) \leq (1 - p^N)^m$.
Proposition 9. If $\set{X_n}_{n \in \N}$ is an adapted process and $\tau$ is a stopping time, then $Y_n = X_{\tau \varmin n}$ is $\mathcal F_n$-measurable (and so $\set{Y_n}_{n \in \N}$ is also an adapted process).
The optional sampling theorem
Let $\set{M_n}_{n \in \N}$ be a martingale, and $\tau$ be a bounded stopping time. Then $\E_n M_\tau = M_{\tau \varmin n}$.
Proof sketch. Let $N = \max \tau$, and note $$ \E_n M_\tau = \one_{\tau \leq n} M_\tau + \sum_{k = n}^N \E_n \one_{\tau = k} M_k = \one_{\tau \leq n} M_\tau + \sum_{k = n}^N \E_n \one_{\tau = k} M_N = \one_{\tau \leq n} M_\tau + \one_{\tau > n} M_n = M_{\tau \varmin n} $$
Remark 11. More generally, the optional sampling theorem holds under either of the following assumptions:
- If $\tau < \infty$ almost surely, and $M_{\tau \varmin k}$ is dominated (i.e. there exists a random variable $X$ such that $\E X < \infty$ and for all $k$, $\abs{M_{\tau \varmin k}} \leq X$).
- If $\E \tau < \infty$ and the increments $M_{k+1} - M_k$ are uniformly bounded (i.e. there exists $C > 0$ such that $\abs{M_{k+1} - M_k} \leq C$ for all $k$).
While we currently do not have the tools to prove this, we will occasionally need this more general version.
Corollary 12. If $M$ is a martingale and $\tau$ is a bounded stopping time then $\E M_\tau = \E M_1$.
Corollary 13. If $M$ is a martingale, and $\tau$ is a stopping time, then $\set{M_{\tau \varmin n}}_{n \in \N}$ is a martingale.
The previous corollary says you can’t make a fair game unfair by stopping early; provided your stopping time satisfies the conditions where the optional sampling theorem applies. You can, easily, construct strategies where the optional sampling theorem doesn’t apply which (seemingly) allow you to profit.
Problem 14 (Exponential martingale). Let $\set{S_n}$ be the simple random walk with $S_0 = 0$.
-
For any $\lambda \in \R$, show that $ M_n = e^{\lambda S_n}/ (\cosh \lambda)^n $ is a martingale.
-
Show that for every $a > 0$ and $N \in \N$, $$ \P\paren[\Big]{\max_{0 \leq n \leq N} S_n \geq a} \leq \exp\paren[\Big]{-\frac{a^2}{2N}} \,. $$
Hint. Let $\tau = \min\set{n \in \N \st S_n \geq a}$. Apply optional sampling to $M_{\tau \varmin N}$, use $\log\cosh\lambda \leq \lambda^2/2$, and optimize over $\lambda > 0$. (Note this is stronger than Hoeffding’s inequality as we control the probability of the maximum.)
Gamblers ruin
Example 15 (Gambling paradox). Let $M_n$ be the simple random walk. Let $\tau = \min \set{ n \in \N \st M_n = 1}$. Clearly $M$ is a martingale, $\tau$ is a stopping time. One can also show $\tau < \infty$ almost surely. However, $\E M_\tau = 1 \neq 0 = M_0 = \E M_1$.
In reality, this doesn’t allow you to profit because $\E \tau = \infty$. Also, for any $N \in \N$, there is a non-zero chance you lose $\dollar N$ before time $\tau$; meaning you will have to find a bank that is infinitely patient, and is willing to cover arbitrarily high losses you may make.
Proposition 16. Let $N \in \N$, $M_n$ be the simple random walk with $M_0 \in \set{0, \dots, N}$. Let $\tau = \min \set{n \in \N \st M_n \in \set{0, N}}$. Then $$ \P( M_\tau = 0 ) = 1 - \frac{M_0}{N} \,,\quad \P( M_\tau = N ) = \frac{M_0}{N} \,,\quad \E \tau = M_0 (N - M_0) \,. $$
Proof sketch.
- Check optional sampling applies using one of the conditions in Remark 11.
- Hence $\E M\tau = M_0$ which gives the first two equalities claimed.
- Check $X_n = M_n^2 - n$ is a martingale and that optional sampling applies, and use optional sampling with the bounded stopping time $\tau \varmin n$, and then send $n \to \infty$.
Proposition 17. Let $M_n$ be the simple random walk with some $M_0 \in \N$, and let $\tau = \min \set{n \in \N \st M_n = 0 }$. Then $\P( \tau < \infty ) = 1$, and $\E \tau = \infty$.
Proof sketch. Say first $M_0 > 0$, and let $N \geq M_0$. Let $\tau_N = \min \set{n \in \N \st M_n \in \set{0, N} }$, and note $\set{\tau < \infty } = \cup_N \set{M_{\tau_N} = 0}$. To prove $\E \tau = \infty$, we need to use the fact that $\E \tau = \lim_{N \to \infty} \E \tau_N = \infty$.
Remark 18. As mentioned in Example 1, this means that even though the game is fair, no matter how large a fortune you start with, you will (almost surely) lose it all. And even if you start with only $\dollar 1$, you will (on average) take infinitely long to lose it.
Lemma 19. Let $\set{\xi_n}_{n \in \N}$ be an i.i.d. adapted process such that $\xi_{n+1}$ is independent of $\mathcal F_n$. Let $X_0 \in \R$ and $X_{n+1} = X_n + \xi_{n+1}$. If $f \colon \R \to \R$ is a function such that $\E f(x + \xi_1) = f(x)$ for every $x \in \R$, then show that $\set{ f(X_n) }_{n \in \N}$ is a martingale.
Proposition 20. Let $\set{\xi_n}$ be i.i.d. random variables with $\P(\xi_n = 1) = p \in (0, 1)$ and $\P(\xi_n = -1) = 1 - p = q$. Suppose $p \neq 1/2$. Let $S_0 = k \in \set{0, \dots, N}$, $S_{n+1} = S_n + \xi_{n+1}$, $\tau = \min \set{n \in \N \st S_n \in \set{0, N}}$. $$ \P(S_\tau = 0) = \frac{\paren{\frac{q}{p}}^k - \paren{\frac{q}{p}}^N} {1 - \paren{\frac{q}{p}}^N} \quad\text{and}\quad \E \tau = \frac{k}{q - p} - \frac{N}{q-p} \paren[\Big]{ \frac{1 - (\frac{q}{p})^k}{1 - (\frac{q}{p})^N} } \,. $$
Proof sketch.
- Use Lemma 19 and find a function $f$ so that $\set{f(S_n)}_{n \in \N}$ is a martingale. (Answer: $f(x) = r^x$ works with $r = q/p$.)
- Check optional sampling applies, and use $\E M_\tau = M_0$ to obtain $\P(S_\tau = 0)$.
- For the second part check $M_n = S_n - (p - q)n$ is a martingale (and that optional sampling applies)
Remark 21. If $p > q$, then the game is biased in the gamblers favor. In this case the probability of eventually going bankrupt converges to $(q/p)^k < 1$ as $N \to \infty$. If $p < q$, then the game is biased against the gambler, and the probability of eventually going bankrupt converges to $1$ as $N \to \infty$.
Sequence waiting time
Let $\set{X_n}$ be i.i.d. $\Bernoulli(1/2)$ random variables, $N \in \N$, and $\omega \in \set{0, 1}^N$ some fixed sequence of length $N$. Let $\tau$ be the first time $\omega$ is observed. Explicitly $$ \tau = \min \set{ n \geq N \st X_{n - N + 1} = \omega_1, X_{n - N + 2} = \omega_2, \dots, X_{n} = \omega_N} \,. $$
Proposition 22. The expected waiting time to see the sequence $\omega$ is $$ \E \tau = \sum_{j \in J} 2^j \quad\text{where}\quad J = \set{ j \in \set{1, \dots, N} \st \operatorname{prefix}_j(\omega) = \operatorname{suffix}_j(\omega) } \,. $$ Here $\operatorname{prefix}_j(\omega) = (\omega_1, \dots, \omega_j)$ and $\operatorname{suffix}_j(\omega) = (\omega_{N - j + 1}, \dots, \omega_N)$.
Remark 23. If $\omega = (1, \dots, 1)$, or $\omega = (0, \dots, 0)$ then this is the same as this problem we did before.
Remark 24. You may be mildly surprised by the fact that any two length $N$ sequences have the same probability of occurring in $N$ i.i.d. trials. However the waiting times to see some of them is longer. The reason for this is common prefix / suffixes. If you enumerate all sequences of length $N + 1$, your sequence $N$ will occur exactly $4$ times. However, a sequence with a common prefix / suffix (e.g. $(0, 0)$) occurs twice in one $N + 1$ length sequence; and so occurs in only $3$ distinct sequences of length $N + 1$. This makes the expected waiting time longer.
Proof sketch. Design a martingale as follows. At time $n$, a gambler enters with $\dollar 1$. Every gambler bets their entire fortune on the sequence in order, and leaves either when they lose, or exhaust the sequence. (So when a gambler first enters, they bet a dollar on $\omega_1$; if they win the next time they bet $\dollar 2$ on $\omega_2$. If they lose they leave with nothing.) Check $M_n = G_n - n$ is a martingale, and that $G_\tau$ is exactly $\sum_J 2^j$. Justify the application of optional sampling to conclude.
Recurrence of random walks
A simple random walk on $\Z^d$ is the process defined by $S_{n+1} = S_n + \xi_{n + 1}$ where $\set{\xi_n}_{n \in \N}$ are i.i.d. and uniformly distributed on $\set{\pm e_1, \dots, e_d}$. (Here $e_i$ is the $i$-th elementary basis vector in $\R^d$). For simplicity, we will assume $S_0 = 0$.
Definition 25. The process $S_n$ is recurrent at $0$ if $\P(S_n = 0 \text{ infinitely often } ) = 1$.
Theorem 26. The above simple random walk is recurrent if and only if $d = 1, 2$.
We already proved this in Proposition 17 when $d = 1$ while studying gamblers ruin. Here’s an independent proof that works in more generality.
Lemma 27. The random walk is recurrent if and only if $\sum_{n \in \N} \P(S_n = 0) = \infty$.
Proof sketch.
- Let $\tau_0 = 0$ and set $\tau_{k+1} = \min \set{ n > \tau_k \st S_n = 0}$.
- Check $\P(\tau_k < \infty) = \P(\tau_1 < \infty)^k$.
- Check recurrence if and only if $\P(\tau_1 < \infty) = 1$.
- Compute the expected number of visits to $0$, and show $\P(\tau_1 < \infty) = 1 \iff \sum \P(S_n = 0 ) = \infty$
Lemma 28. The random walk is recurrent when $d = 1$.
Proof sketch. Note $\P(S_{2n} = 0) = \frac{1}{2^{2n}} \binom{2n}{n}$. We claim $\P(S_{2n} = 0) \approx 1/\sqrt{n}$. This can be shown in several ways:
- (Most straightforward): Use Stirling’s formula
- Use the Bionomial theorem to obtain $$ \sum_{n=0}^\infty \binom{2n}{n}x^n =\frac1{\sqrt{1-4x}}, \qquad 0\leq x<\frac14. $$ and let $x \to 1/4$.
- By Chebychev $\P( |S_{2n} - n| \geq \sqrt{n} ) \leq 1/2$, and use the fact that $\binom{2n}{n}$ maximizes $\binom{2n}{k}$ for $k \in \set{0, \dots, 2n}$, and the fact that there are at most $2 \sqrt{n} + 1$ integers with $\abs{S_{2n} - n} < \sqrt{n}$ to get $$ \P(S_{2n} = 0) \geq \frac{1}{4 \sqrt{n} + 2} \,. $$
Lemma 29. Consider the diagonal random walk, where each coordinate of $S_n$ is an independent simple random walk. (That is $e_i \cdot S_{n+1} = e_i \cdot S_n + \xi_{n+1, i}$, where $\set{\xi_{n, i}}_{n \in \N, 1 \leq i \leq d}$ are i.i.d. Radamacher random variables.)
The diagonal random walk is recurrent if and only if $d = 1, 2$.
Proof sketch. Since the coordinates are independent $\P(S_{2n} = 0) = (2^{-2n} \binom{2n}{n})^d$, and using the asymptotics in Lemma 28 the lemma follows.
With a little work one can show the same recurrence results for the standard random walk (and not just the diagonal one). Here’s a nice visualization. (Note, even though it returns to the origin infinitely often in 2D, the expected time to return is infinite; so you won’t see too many returns!) One thing that’s worth noting is that after many steps, the trajectories start looking like Brownian motion; that’s no coincidence.