What does Attribution, Bandits and Customer Lifetime Value conclude, in numbers, about “What Is a Customer Still Worth? BG/NBD, Gamma-Gamma and the Illusion of Rising Retention”?

Answer: BG/NBD describes the purchasing and dropout of non-contractual customers with four parameters and depends only on frequency and recency; the series for the \(_2F_1\) in its expectation converges very slowly for long horizons, and Euler's integral after Pfaff's transformation and a change of variable computes it stably, the two algorithms checking each other. The Gamma-Gamma model gives a shrunken expected spend but assumes spend and frequency are independent; in a fictional example in which frequent buyers spend less, violating the assumption overstates revenue by 49 %. Period retention rising over time is usually a sorting effect of heterogeneity: the sBG reproduces Fader and Hardie's parameters exactly and shows that "multiplying retention rates" understates expected lifetime by about a third. Simpson's paradox is a different thing: every subgroup gets worse while the pooled figure improves.

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

A. 946 fictional repeat buyers: refitted p 7.72, q 3.50, gamma 11.88
population mean spend 36.60 (published parameters35.22)
correlation of x with average spend-0.075
B. 104-week CLV, 10 % a year, published BG/NBD and Gamma-Gamma parameters
customer (x, t_x, zbar) E[spend] E[orders, 104 wk] CLV
(1, 30.0, 60.0)52.45 1.48 71.41
(6, 38.0, 25.0)25.70 8.40 198.96
(6, 12.0, 25.0)25.70 0.20 4.73
C. 1,500 fictional buyers: revenue per buyer E[x m] (x repeat orders, m mean
spend per order) against E[x] E[m], the product used when spend is
modelled separately from frequency
independent E[x m]106.6 E[x] E[m] 109.4 (+3%)
heavy buyers spend less E[x m]85.3 E[x] E[m] 126.7 (+49%)

Key formula

\[L = \frac{B(a, b+x)}{B(a, b)}\,\frac{\Gamma(r+x)\,\alpha^r}{\Gamma(r)\,(\alpha+T)^{r+x}} + \delta_{x>0}\,\frac{B(a+1, b+x-1)}{B(a, b)}\,\frac{\Gamma(r+x)\,\alpha^r}{\Gamma(r)\,(\alpha+t_x)^{r+x}},\]
Show the full program
# Gamma-Gamma spend model (Colombo & Jiang 1999; Fader, Hardie & Lee 2005b): each
# transaction value ~ Gamma(p, nu), nu ~ Gamma(q, gamma) across customers, ASSUMED
# independent of the purchase process. A: fictional repeat buyers simulated with the
# published CDNOW estimates (p 6.25, q 3.74, gamma 15.44), refitted by maximum
# likelihood. B: expected spend E(Z | x, zbar) and a 104-week discounted CLV from the
# BG/NBD conditional expectation (FHL 2005a, eq. 10) for three fictional customers.
# C: when heavy buyers spend less per order, multiplying expected transactions by
# expected spend (the independence assumption) overstates revenue.
import math, random, statistics

# --- helpers repeated from earlier programs, so that this one runs on its own ---
def f21_series(a, b, c, z, tol=1e-12, kmax=200_000):
    term, s, k = 1.0, 1.0, 0
    while abs(term) > tol * abs(s) and k < kmax:
        term *= (a + k) * (b + k) / ((c + k) * (k + 1)) * z; s += term; k += 1
    return s, k

def nelder_mead(f, x0, it=300):
    n = len(x0)
    pts = [list(x0)] + [[x * (1.2 if i == j else 1) for j, x in enumerate(x0)]
                        for i in range(n)]
    for _ in range(it):
        pts.sort(key=f); c = [sum(p[i] for p in pts[:-1]) / n for i in range(n)]
        w = pts[-1]; r = [c[i] + (c[i] - w[i]) for i in range(n)]
        if f(r) < f(pts[0]):
            e = [c[i] + 2 * (c[i] - w[i]) for i in range(n)]
            pts[-1] = e if f(e) < f(r) else r
        elif f(r) < f(pts[-2]):
            pts[-1] = r
        else:
            k = [c[i] + 0.5 * (w[i] - c[i]) for i in range(n)]
            if f(k) < f(w):
                pts[-1] = k
            else:
                pts = [pts[0]] + [[pts[0][i] + 0.5 * (p[i] - pts[0][i]) for i in range(n)]
                                  for p in pts[1:]]
    return min(pts, key=f)
# --- end of repeated helpers ---

BG = (0.243, 4.414, 0.793, 2.426)

def gg_ll(th, data):
    p, q, g = th
    if min(th) <= 0:
        return -1e18
    ll = 0.0
    for x, zbar in data:
        ll += (math.lgamma(p * x + q) - math.lgamma(p * x) - math.lgamma(q)
               + q * math.log(g) + (p * x - 1) * math.log(zbar) + p * x * math.log(x)
               - (p * x + q) * math.log(g + x * zbar))
    return ll

def e_spend(x, zbar, p, q, g):
    return p * (g + x * zbar) / (p * x + q - 1)

def ey(t, x, tx, T, r, al, a, b):
    z = t / (al + T + t)
    num = (a + b + x - 1) / (a - 1) * (1 - ((al + T) / (al + T + t)) ** (r + x)
                                       * f21_series(r + x, b + x, a + b + x - 1, z)[0])
    den = 1 + (x > 0) * a / (b + x - 1) * ((al + T) / (al + tx)) ** (r + x)
    return num / den

def clv(x, tx, T, m, weeks=104, annual=0.10):
    d = (1 + annual) ** (1 / 52); prev, tot = 0.0, 0.0
    for w in range(1, weeks + 1):
        cur = ey(w, x, tx, T, *BG); tot += (cur - prev) / d ** w; prev = cur
    return tot * m, prev

def spenders(rng, n, p, q, g, dep=0.0):
    out = []
    for _ in range(n):
        x = 1 + min(int(rng.expovariate(0.4)), 20)        # repeat transactions
        nu = rng.gammavariate(q, 1 / g) * math.exp(dep * (x - 3))
        out.append((x, statistics.fmean(rng.gammavariate(p, 1 / nu) for _ in range(x)),
                    p / nu))                              # (x, zbar, true mean spend)
    return out

def pearson(x, y):
    """Pearson correlation (statistics.correlation needs Python 3.10+)."""
    mx, my = statistics.fmean(x), statistics.fmean(y)
    sxy = math.fsum((a - mx) * (b - my) for a, b in zip(x, y))
    sxx = math.fsum((a - mx) ** 2 for a in x); syy = math.fsum((b - my) ** 2 for b in y)
    return sxy / math.sqrt(sxx * syy)

if __name__ == "__main__":
    PUB = (6.25, 3.74, 15.44)
    data = spenders(random.Random(1999), 946, *PUB)
    th = nelder_mead(lambda t: -gg_ll(t, [d[:2] for d in data]), [3.0, 3.0, 10.0], 400)
    mean_pop = th[0] * th[2] / (th[1] - 1)
    print(f"A. 946 fictional repeat buyers: refitted p {th[0]:.2f}, q {th[1]:.2f},"
          f" gamma {th[2]:.2f}")
    print(f"   population mean spend {mean_pop:.2f}"
          f" (published parameters: {PUB[0] * PUB[2] / (PUB[1] - 1):.2f})")
    print(f"   correlation of x with average spend: "
          f"{pearson([d[0] for d in data], [d[1] for d in data]):+.3f}")
    print("B. 104-week CLV, 10 % a year, published BG/NBD and Gamma-Gamma parameters")
    print("   customer (x, t_x, zbar)     E[spend]   E[orders, 104 wk]  CLV")
    for x, tx, zb in ((1, 30.0, 60.0), (6, 38.0, 25.0), (6, 12.0, 25.0)):
        m = e_spend(x, zb, *PUB); v, n = clv(x, tx, 39.0, m)
        print(f"   ({x}, {tx:4.1f}, {zb:4.1f})              {m:6.2f}       {n:6.2f}"
              f"        {v:7.2f}")
    print("C. 1,500 fictional buyers: revenue per buyer E[x m] (x repeat orders, m mean")
    print("   spend per order) against E[x] E[m], the product used when spend is")
    print("   modelled separately from frequency")
    for dep, lab in ((0.0, "independent"), (0.25, "heavy buyers spend less")):
        d2 = spenders(random.Random(7), 1500, *PUB, dep)
        xm = statistics.fmean(d[0] * d[2] for d in d2)
        pm = statistics.fmean(d[0] for d in d2) * statistics.fmean(d[2] for d in d2)
        print(f"   {lab:24s} E[x m] {xm:6.1f}   E[x] E[m] {pm:6.1f}"
              f"   ({pm / xm - 1:+.0%})")

Single source and citation

Fan, Y. (2026). Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels (Version 1.0.0), Chapter 5: What Is a Customer Still Worth? BG/NBD, Gamma-Gamma and the Illusion of Rising Retention. 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