What does Attribution, Bandits and Customer Lifetime Value conclude, in numbers, about “Learning While Earning: Thompson Sampling and the Bias of Adaptive Experiments”?

Answer: Thompson sampling allocates traffic by "the posterior probability of being the best variant"; in the fictional three-creative example it cuts regret from 33.9 conversions for the A/B/C test to 26.1, but lowers the share of runs that pick the best creative from 83 % to 79 %. When two variants are identical, Thompson allocation leaves the mean sample conversion rate 0.33 points too low and nominal intervals cover only 82.5 % of the time; inverse-propensity weighting with the known allocation probabilities removes the bias. The author's framework is right to present bandits as a tool for "optimising conversion", but they should not be used as a tool for measuring effects; the two goals differ, and which one is wanted should be stated when the experiment is designed.

Scope of the numbers: Which advertising channel should a sale be credited to? When may an A/B test stop? What is a customer still worth? This book presents mathematical models for teaching and research and is not marketing, investment or legal advice. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's models and hypotheses; all data in the book are fictional or simulated.

中文版

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: 26.1, 33.9, 79, 83

rates (0.04, 0.045, 0.05), 10,000 visitors, 100 replications
policy regret (conv.) traffic on best final pick correct
A/B/C 6,000 then best33.9 (sd 7.2) 52.4% 83%
epsilon-greedy 10 %25.8 (sd 22.6) 60.7% 74%
Thompson sampling26.1 (sd 14.6) 60.5% 79%
Thompson: visitors shown the 4.0 % creative, median 1037, min 122, max 5496
always the best0 regret; uniform random: 50.0
Show the full program
# Three ad creatives with FICTIONAL conversion rates 4.0 %, 4.5 % and 5.0 %; 10,000
# visitors. Policies: (1) A/B/C test with equal split for the first 6,000 visitors,
# then the observed best for the rest; (2) epsilon-greedy (10 %); (3) Thompson sampling
# with Beta(1, 1) priors (Thompson 1933). Reported over 100 replications: expected
# regret (conversions lost against always showing the best creative), share of
# traffic on the best arm, and how often the final pick is the best arm.
import random, statistics

RATES = (0.040, 0.045, 0.050); N = 10_000; REPS = 100

def run(rng, policy):
    s, f = [0, 0, 0], [0, 0, 0]; regret, best = 0.0, 0
    for t in range(N):
        if policy == "ab":
            k = t % 3 if t < 6000 else max(range(3), key=lambda i: s[i] / (s[i] + f[i]))
        elif policy == "eps":
            if rng.random() < 0.10 or t < 30:
                k = rng.randrange(3)
            else:
                k = max(range(3), key=lambda i: (s[i] + 1) / (s[i] + f[i] + 2))
        else:
            k = max(range(3), key=lambda i: rng.betavariate(s[i] + 1, f[i] + 1))
        if rng.random() < RATES[k]:
            s[k] += 1
        else:
            f[k] += 1
        regret += RATES[2] - RATES[k]; best += k == 2
    pick = max(range(3), key=lambda i: (s[i] + 1) / (s[i] + f[i] + 2))
    return regret, best / N, pick == 2, [s[i] + f[i] for i in range(3)]

if __name__ == "__main__":
    print(f"rates {RATES}, {N:,} visitors, {REPS} replications")
    print("policy                 regret (conv.)   traffic on best   final pick correct")
    for pol, lab in (("ab", "A/B/C 6,000 then best"), ("eps", "epsilon-greedy 10 %"),
                     ("ts", "Thompson sampling")):
        rng = random.Random(1933)
        R = [run(rng, pol) for _ in range(REPS)]
        reg = [r[0] for r in R]
        mr, sr = statistics.fmean(reg), statistics.stdev(reg)
        print(f"   {lab:22s} {mr:6.1f} (sd {sr:4.1f})"
              f"     {statistics.fmean(r[1] for r in R):6.1%}"
              f"            {sum(r[2] for r in R) / REPS:5.0%}")
        if pol == "ts":
            n_worst = sorted(r[3][0] for r in R)
            print(f"   Thompson: visitors shown the 4.0 % creative,"
                  f" median {n_worst[REPS // 2]}"
                  f", min {n_worst[0]}, max {n_worst[-1]}")
    unif = N * (RATES[2] - sum(RATES) / 3)
    print(f"always the best: 0 regret; uniform random: {unif:.1f}")

Single source and citation

Fan, Y. (2026). Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels (Version 1.0.0), Chapter 4: Learning While Earning: Thompson Sampling and the Bias of Adaptive Experiments. 5D Library. https://doi.org/10.5281/zenodo.23836264

DOI: 10.5281/zenodo.23836264 · Read the monograph · 5DL-B-048 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026048,
  author    = {Fan, Yafu},
  title     = {Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  doi       = {10.5281/zenodo.23836264},
  url       = {https://doi.org/10.5281/zenodo.23836264}
}

Other chapter answers in this book