What does Martingales, Stopping Times and Stop-Loss Bounds conclude, in numbers, about “Closing the Loop: the Three-Line Register of a Trial Budget, the Stop-Loss Bound Calculator and a Pre-Registered Protocol”?

Answer: Chapter 8 gives the three-line register of a trial budget, the Trial Stop-Loss Bound Calculator and a pre-registered protocol (601 trials per group). Marked boxes separate published evidence, runnable Python calculations (21 programs), classical sources and the author's hypotheses.

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: 601

per trial: stop -3 mean 1.025 sd 5.334; no line mean 0.000 sd 7.211
difference 1.025, pooled sd 6.343, effect size 0.162
normal formula601 trials per arm (two-sided 0.05, power 0.8)
simulated power with 601 per arm0.802
simulated power with 1202 per arm0.981
if the true gain were half as large2404 per arm
Show the full program
# Chapter 8. p82: Sample size for the pre-registered test of the core
# business claim (Chapter 5): with unknown quality, a registered stop
# line earns more per trial than running every trial to its deadline.
# Model as in p51: good p = 0.6 / bad p = 0.4, prior 1/2, deadline 26,
# stop line -3 versus none. Exact means and sds per trial; two-arm
# sample size by the normal formula (two-sided 0.05, power 0.8); then
# a fixed-seed simulation of the planned test. Illustrative.
from fractions import Fraction
import math
import random
import statistics

N, LINE = 26, 3


def outcome_dist(p, b):
    q = 1 - p
    live = {0: Fraction(1)}
    out = {}
    for t in range(1, N + 1):
        new = {}
        for s, pr in live.items():
            new[s + 1] = new.get(s + 1, Fraction(0)) + pr * p
            new[s - 1] = new.get(s - 1, Fraction(0)) + pr * q
        live = {}
        for s in sorted(new):
            if (b is not None and s <= -b) or t == N:
                out[s] = out.get(s, Fraction(0)) + new[s]
            else:
                live[s] = new[s]
    return out


def mixture(b):
    d = {}
    for p in (Fraction(3, 5), Fraction(2, 5)):
        for s, pr in outcome_dist(p, b).items():
            d[s] = d.get(s, Fraction(0)) + pr / 2
    vals = sorted(d)
    mean = math.fsum(s * float(d[s]) for s in vals)
    var = math.fsum((s - mean) ** 2 * float(d[s]) for s in vals)
    return vals, [float(d[s]) for s in vals], mean, math.sqrt(var)


v1, w1, m1, s1 = mixture(LINE)
v0, w0, m0, s0 = mixture(None)
delta = m1 - m0
sd = math.sqrt((s1 * s1 + s0 * s0) / 2)
z = 1.959963984540054 + 0.8416212335729143
n_arm = math.ceil(2 * (z * sd / delta) ** 2)
print("per trial: stop -%d mean %.3f sd %.3f; no line mean %.3f sd %.3f"
      % (LINE, m1, s1, m0, s0))
print("difference %.3f, pooled sd %.3f, effect size %.3f" % (
    delta, sd, delta / sd))
print("normal formula: %d trials per arm (two-sided 0.05, power 0.8)"
      % n_arm)
rng = random.Random(20261182)
for n in (n_arm, 2 * n_arm):
    hits = 0
    for _ in range(4000):
        a = rng.choices(v1, w1, k=n)
        b = rng.choices(v0, w0, k=n)
        se = math.sqrt(statistics.variance(a) / n
                       + statistics.variance(b) / n)
        if abs(statistics.fmean(a) - statistics.fmean(b)) / se > 1.96:
            hits += 1
    print("simulated power with %d per arm: %.3f" % (n, hits / 4000))
print("if the true gain were half as large: %d per arm" % (4 * n_arm))

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 8: Closing the Loop: the Three-Line Register of a Trial Budget, the Stop-Loss Bound Calculator and a Pre-Registered Protocol. 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