What does Martingales, Stopping Times and Stop-Loss Bounds conclude, in numbers, about “A Conservation Law for Fair Games: Martingales, Bounded Stopping Times and the Optional Stopping Theorem”?
Answer: A martingale is a cumulative process that neither gains nor loses; a stopping time is a rule that looks only at the past; the optional stopping theorem says that under a bounded stopping time the expectation of a martingale is conserved. Program p11 displays this conservation exactly on six rules, whose win rates range from 0.300 to 0.824 while every expectation is zero. Program p12 shows that the theorem fails only when the stopping time is unbounded, and that the price of the failure is a loss on a vanishing set of paths and an average wait that both grow without limit, which cannot be collected within finite capital and finite time. What, then, are the accounts of the most common and most tempting rule of all, doubling after a loss, when capital is finite? That is the question of the next chapter.
Scope of the numbers: Its parameters are illustrative; all calculations are generated by its programs. It is not individual financial advice, does not encourage gambling of any kind, and analyses doubling only as a counter-example.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.300, 0.824
| fair walk, deadline N = 20 periods, exact enumeration | |||||||
| rule | E[S_T] | P(+) | P(-) | E[T] | sd | worst P(worst) | |
| hold | 0 | 0.412 | 0.412 | 20.00 | 4.47 | -20 | 0.0000 |
| first+1 | 0 | 0.824 | 0.160 | 6.22 | 2.49 | -20 | 0.0000 |
| +3/-3 | 0 | 0.481 | 0.481 | 8.47 | 2.91 | -3 | 0.4625 |
| +2/-8 | 0 | 0.664 | 0.281 | 10.44 | 3.23 | -8 | 0.0712 |
| +5/-2 | 0 | 0.300 | 0.657 | 8.77 | 2.96 | -2 | 0.6566 |
| trail3 | 0 | 0.322 | 0.572 | 10.47 | 3.24 | -3 | 0.2495 |
| every row: E[S_T] is exactly 0 (a Fraction, not a rounded float) |
Key formula
Show the full program
# Chapter 1. p11: Six stopping rules on a fair walk all keep mean zero.
# Model: a fair business trial. Each period the running result moves
# +1 or -1 unit with probability 1/2 each (a martingale). A stopping
# rule may look at the whole past but not the future; every rule here
# is also cut at the deadline N = 20, so the stopping time is bounded
# and Doob's optional stopping theorem says E[S_T] = S_0 = 0. Exact
# enumeration with fractions; the rules and N are illustrative.
from fractions import Fraction
import math
N = 20
HALF = Fraction(1, 2)
def rule_hold(s, m):
return False
def rule_first_up(s, m):
return s >= 1
def rule_3_3(s, m):
return s >= 3 or s <= -3
def rule_2_8(s, m):
return s >= 2 or s <= -8
def rule_5_2(s, m):
return s >= 5 or s <= -2
def rule_trail3(s, m):
return m - s >= 3
RULES = [("hold", rule_hold), ("first+1", rule_first_up),
("+3/-3", rule_3_3), ("+2/-8", rule_2_8),
("+5/-2", rule_5_2), ("trail3", rule_trail3)]
def run(rule):
live = {(0, 0): Fraction(1)}
ends = [] # (final value, time, probability)
for t in range(1, N + 1):
new = {}
for (s, m), pr in live.items():
for d in (1, -1):
ns = s + d
key = (ns, max(m, ns))
new[key] = new.get(key, Fraction(0)) + pr * HALF
live = {}
for key in sorted(new):
s, m = key
if rule(s, m) or t == N:
ends.append((s, t, new[key]))
else:
live[key] = new[key]
return ends
print("fair walk, deadline N = %d periods, exact enumeration" % N)
print("%-9s %6s %6s %6s %6s %6s %6s %8s" % (
"rule", "E[S_T]", "P(+)", "P(-)", "E[T]", "sd", "worst", "P(worst)"))
for name, rule in RULES:
ends = run(rule)
mean = Fraction(0)
for s, t, pr in ends:
mean += s * pr
pw = math.fsum(float(pr) for s, t, pr in ends if s > 0)
pl = math.fsum(float(pr) for s, t, pr in ends if s < 0)
et = math.fsum(t * float(pr) for s, t, pr in ends)
var = math.fsum(s * s * float(pr) for s, t, pr in ends)
worst = min(s for s, t, pr in ends)
pwo = math.fsum(float(pr) for s, t, pr in ends if s == worst)
print("%-9s %6s %6.3f %6.3f %6.2f %6.2f %6d %8.4f" % (
name, str(mean), pw, pl, et, math.sqrt(var), worst, pwo))
print("every row: E[S_T] is exactly 0 (a Fraction, not a rounded float)")Single source and citation
Fan, Y. (2026). Doob's Martingales and the Optional Stopping Theorem: the Doubling Fallacy and Rigorous Stop-Loss Bounds for Business Trials (Version 1.0.0), Chapter 1: A Conservation Law for Fair Games: Martingales, Bounded Stopping Times and the Optional Stopping Theorem. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-249 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026249,
author = {Fan, Yafu},
title = {Doob's Martingales and the Optional Stopping Theorem: the Doubling Fallacy and Rigorous Stop-Loss Bounds for Business Trials},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 2 · The Exact Accounts of the Doubling Ladder: Finite Capital, Tail Losses and Doubling After a Loss
- Chapter 3 · Wald's Identities: a Stop Line Sells Time
- Chapter 4 · Quitting While Ahead Changes Only the Shape: the Win-Rate Illusion and Selling Winners While Holding Losers
- Chapter 5 · The Learning Value of a Stop Line: Lines of Belief, the Gap Between Good and Bad, and Escalating Sunk Costs
- Chapter 6 · Peeking and Early Stopping: Optional Stopping and Test Martingales in Online Experiments
- Chapter 7 · Eastern and Western Sources Examined: Laozi on Knowing Enough and Knowing When to Stop, and Bernoulli's Logarithm
- Chapter 8 · Closing the Loop: the Three-Line Register of a Trial Budget, the Stop-Loss Bound Calculator and a Pre-Registered Protocol