5D Library › Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels · 中文
Preface: Attribution, Experiments and the Value of a Customer
Note
Purpose and risk notice: please read this first. This book presents mathematical models for teaching and research. It is not marketing, investment, financial or legal advice. Every user, path, conversion, advertising budget, customer and transaction in the book is fictional or simulated, not data from any real advertiser, platform, brand or customer; no data from the author’s businesses or their clients are used. Published studies are cited only for what they found under their own conditions and cannot be carried over directly to a reader’s business. The book recommends no advertising platform, attribution software or media-buying service, and offers no method that “guarantees”, “always wins”, “lifts conversion by X %” or is “proven optimal”. Its models hold only under the assumptions stated; real user behaviour, platform algorithms and competitors can violate them at any time. Advertising costs money, and any budget decision based on the book’s models can lose it.
A user sees a short video on social media, opens a promotional email a few days later, and finally types the brand’s name into a search engine, clicks an ad and buys. Which of these should get the credit for the sale? A marketing team usually has a report that answers the question, and the numbers in that report decide next quarter’s budget. The same team is running a dozen A/B tests at once and checks each morning whether a variant has become “significant”; the finance department multiplies “63 % first-year retention” forward to estimate what a customer is worth over a lifetime. This book asks which of these practices are supported by mathematics and evidence, which need qualifying, and which are wrong.
Answering takes four layers of tools. The first is causality: does a channel’s “contribution” mean that it appeared on the path to a conversion, or that without it the conversion would not have happened? The second is experimentation: how to look at results while the data accumulate without fooling oneself, and what learn-as-you-go algorithms such as bandits give up. The third is stochastic models of a customer base: when we cannot see a customer “leave”, how to infer from purchase records who is still active and how much they will buy, and why the retention rate of a group “rises” over time. The fourth is dynamic control: how the speed at which a new product diffuses relates to how an advertising budget should be spread, and whether a static optimality rule can be stretched across a whole life cycle.
What the book covers
Chapter 1 distinguishes rule-based attribution (last click, first click, linear) from incrementality and reviews the evidence from randomised holdouts and ghost ads; Chapter 2 treats Shapley-value attribution and the removal effect of an absorbing Markov chain, their dependence on the characteristic function, their disagreement on synergistic channels, and why on observational data they are still not causal increments; Chapter 3 computes exactly how optional stopping inflates the type I error, and covers group-sequential designs and always-valid inference; Chapter 4 treats Thompson-sampling bandits, how their goal differs from that of an A/B test, and the bias of estimates under adaptive allocation; Chapter 5 covers the BG/NBD and Gamma-Gamma models, the computation of the Gauss hypergeometric function, and the difference between “rising retention” caused by heterogeneity and Simpson’s paradox; Chapter 6 covers the Bass diffusion model, the Dorfman–Steiner condition and the author’s model of whole-life acquisition spend; Chapter 7 reads these beside the “Initial Estimates” and “Strategic Dispositions” chapters of the Sunzi; and Chapter 8 offers a four-step checklist and a pre-registered simulation benchmark.
The book neighbours several others in 5D Library; where they overlap, it only recaps briefly, cites the earlier book and does not repeat its programs. Book 6, The Economics of Attention, wrote the conversion funnel as an absorbing Markov chain and computed the elasticity of each stage (Chapter 2 borrows only the absorbing-chain computation, and its subject is attribution, not funnel elasticities). Book 25, Social Network Topology, Structural Holes and Mathematical Models of Complex Contagion, treated simple and complex contagion (the Bass model of Chapter 6 is its simplest, fully mixed version). Book 26, Probabilistic Judgement, Brier-Score Calibration and the Statistical Theory of the Wisdom of Crowds, treated probability judgement and calibration. Book 33, Scientific Methodology, Falsifiability and the Mathematical Statistics of the Replication Crisis, treated optional stopping, the researcher-degrees-of-freedom simulation of Simmons and co-authors, pre-registration and the statistical properties of decision rules (Chapter 3 gives only the exact optional-stopping curve, and Chapter 8 follows Book 33’s decision-rule format). Book 42, Bayesian Search, the Secretary Problem and Gittins Indices, treated the exploration–exploitation trade-off, Gittins indices, Thompson sampling and UCB (Chapter 4 only recaps, and concentrates on estimation bias in marketing experiments). Books 16 and 26 read the “Empty and Full”, “Planning Offensives”, “Nine Variations” and “Initial Estimates” chapters of the Sunzi; Chapter 7 reads only the sentence on shi in “Initial Estimates” and the chapter “Strategic Dispositions”.
Claims corrected after checking
Several points in the author’s framework needed correcting, supplementing or qualifying after checking. Each chapter says so where it arises, and the accompanying editorial notes list them together.
- “Shapley values and Markov removal effects are exact multi-touch attribution.” Last click is indeed biased, but on observational data Shapley values and removal effects are not causal increments either: they allocate a correlation, “appearing on the path to a conversion”. When ads are targeted at people who were more likely to buy anyway, observational Shapley values inherit that selection bias. In a fictional world with known true increments, the program shows that with targeting the observational Shapley shares are off by 13.1 percentage points and the Markov removal-effect shares by 13.7, the same order as last click’s 18.1; only when exposure is unrelated to purchase intent does the Shapley error fall to 2.0 points. The “exactness” of the Shapley value means only that, for a given characteristic function , it satisfies exactly the four axioms of efficiency, symmetry, null player and additivity (Shapley 1953); how is estimated from observed paths determines what the result means (Dalessandro et al. 2012; Singal et al. 2022). The causal benchmark is a randomised incrementality experiment (Lewis and Rao 2015; Gordon et al. 2019; Johnson et al. 2017) (Chapters 1 and 2).
- “Peeking at A/B-test p-values sends false positives soaring to 25 %+.” Right in direction; the number needs qualifying. With a nominal two-sided , equally spaced looks and the critical value 1.96 at each look, the program computes by numerical integration: 8.3 % with 2 looks, 14.2 % with 5, 19.3 % with 10, 24.8 % with 20 and 37.4 % with 100, tending to 1 as the number of looks grows without bound (Armitage et al. 1969). So “25 % or more” holds only from about 20 looks; and looking is not itself the error, failing to fix a stopping rule in advance is. Group-sequential designs and always-valid inference allow interim looks while controlling the error rate (Pocock 1977; O’Brien and Fleming 1979; Johari et al. 2022) (Chapter 3).
- “Simpson’s paradox makes the aggregate retention curve appear to rise.” Period-by-period retention of a customer group rising over time is usually a sorting effect of heterogeneity: the customers most prone to churn leave first, those who remain are on average less prone, and no individual’s churn probability changes at all (Fader and Hardie 2007; Vaupel and Yashin 1985). It is related to Simpson’s paradox (both come from a change of composition) but is not the same thing: Simpson’s paradox is an association with the same direction in every subgroup that reverses when the subgroups are pooled (Simpson 1951). The program reproduces Fader and Hardie’s parameters exactly with the sBG model (, ), and separately builds a genuine Simpson’s paradox: retention falls by 5 points in both acquisition channels while pooled retention rises from 28.0 % to 45.0 % (Chapter 5).
- The sources and computation of BG/NBD and Gamma-Gamma. BG/NBD is from Fader, Hardie and Lee’s 2005 paper in Marketing Science (Fader et al. 2005a); the Gamma-Gamma spend model comes from the same three authors’ other 2005 paper, in the Journal of Marketing Research (Fader et al. 2005b), building on an idea of Colombo and Jiang (1999) (Colombo and Jiang 1999). The author’s framework cites them as one paper; they are separated. The in the closed form for has approaching 1 as grows, so the power series converges very slowly (21,479 terms at weeks); and Euler’s integral has an integrand that diverges at an endpoint when , so the trapezoidal or Simpson’s rule cannot be applied directly. The program first moves to the negative half-line with Pfaff’s transformation and then changes variables; the two algorithms agree to better than one part in a million. Gamma-Gamma assumes that spend per transaction is independent of purchase frequency, and this assumption is written into the boundaries (Chapter 5).
- Thompson sampling “optimises conversion”. Multi-armed bandits are designed to reduce cumulative regret, not to estimate each variant’s effect accurately. The program shows that when two variants are identical, after Thompson allocation the mean sample conversion rate is 0.33 points too low and the nominal 95 % confidence interval covers zero only 82.5 % of the time; inverse-propensity weighting with the known allocation probabilities removes the bias (Nie et al. 2018; Hadad et al. 2021). Bandits and A/B tests answer different questions (Chapter 4).
- “Combining the Bass diffusion equation with the Dorfman–Steiner theorem to find the whole-life optimal acquisition spend.” The Bass equation is as stated (Bass 1969). The Dorfman–Steiner condition, “the optimal advertising-to-sales ratio equals the advertising elasticity divided by the price elasticity”, checks out (Dorfman and Steiner 1954), but it is a static profit-maximisation condition with no diffusion dynamics in it and cannot by itself give a “whole-life” allocation; the dynamic problem needs advertising written into the state equation, as Nerlove and Arrow and Horsky and Simon did (Nerlove and Arrow 1962; Horsky and Simon 1983). The book’s whole-life model is the author’s model: with a concave advertising response, optimal spend is front-loaded, below 1 thousand from month 10 and zero by month 12, and earns 8.3 % more than spreading the same budget evenly; on one S-shaped response curve, alternate-month pulsing beats even spending at lower monthly budgets (up to 30 thousand) and even spending is better from 32.5 thousand, so the switch lies between 30 and 32.5 thousand, which is neither the inflection point of the curve (about 23.1 thousand) nor exactly the static break-even (about 28.3 thousand) (Chapter 6).
- The Sunzi quotation and its variant. “激水之疾,至于漂石者,势也;鸷鸟之疾,至于毁折者,节也” agrees with the common online transcriptions; the author’s framework has “故善战者,其势险,其节短”, whereas every common transcription checked reads “是故善战者”, and the missing 是 is restored (曹操 等 注,杨丙安 校理 1999). These quotations have been checked only against online transcriptions and await confirmation against Yang Bing’an’s printed edition. The author’s framework notes that 疾 “is also written 击”: the Daizhige transcriptions of the Sunzi (Siku edition) and of the Sunzi jizhu both read 疾, the Chinese Text Project transcription reads 擊, and, according to Giles’s annotated translation of 1910, the quotation in the Song encyclopaedia Taiping yulan reads 击 (Giles 1910). The book follows the Eleven Commentaries in reading 疾, and asks that the collation notes of Yang Bing’an’s edition be checked. Some online transcriptions read 扩弩 or 张弩, the former a faulty simplification of 彍; the book reads 彍弩. All ancient–modern comparisons are marked as analogies (Chapter 7).
- The Chapter 8 study. The book chooses a simulation benchmark rather than a holdout experiment with real advertisers, for reasons given in Chapter 8; the single primary outcome is “the difference between the mean absolute errors of last click and observational Shapley against the true incremental shares”. The study tests only how the methods perform in a simulated world whose truth is known; it tests the effect of no real advertising (Chapter 8).
How to read the boxes
As in the other books of 5D Library, statements of different kinds are marked separately.
Evidence
Evidence boxes report published research findings, with sources.
Calculation
Calculation boxes give short Python programs. Each runs as is in a standard Python 3 environment, uses only the standard library and fixed random seeds, and is followed by its actual output. Users, paths, conversions, spend and customers in the book are fictional or synthetic; parameters are illustrative values, not estimates for any real advertisement, platform or market.
Hypothesis · not established
Hypothesis boxes contain the author’s ideas, marked “not established”, with a statement of what result would show them to be wrong. The author’s own models and definitions are marked “the author’s model” in the text.
Source text
Source boxes quote classical texts, with a plain-language explanation.
Note
Note boxes give reminders and explain choices.
About this edition
This is version 1.0.0, the first complete edition: a preface and eight chapters, in Chinese and English. The book contains 16 Python programs and 5 vector figures. The text, boxes and code were drafted with an AI writing tool from the author’s title, framework and notes; the author is responsible for reviewing and revising them and for checking the sources. AI-drafted text can get bibliographic details wrong; corrections are welcome through the 5D Library website. The fictional user world of Chapter 1, the synergy world of Chapter 2, the whole-life spend model of Chapter 6, the goodwill-stock model of Chapter 7 and the pilot generator of Chapter 8 are the author’s models; their mathematical properties are not evidence about the effects of real advertising.
Disclosure
The author uses the works of 5D Library, including this book, as the methodological basis of his community courses, the 5D Ascension Cards (Dimensional Shift Card Decks) and the Yafu AI knowledge base, and therefore has a commercial interest in the subject of this book. The book promotes no course, card deck or service; the Chapter 8 trial is designed to be run and analysed by researchers independent of the author’s business and does not recruit from the author’s community, students or customers; all the code and the study protocol are published openly for anyone to check. The author founded and runs Asia Influencer X and Yafu Global, which work in influencer marketing, live-stream commerce and digital marketing (including ad buying, performance attribution and customer acquisition) and use the attribution and experimentation methods discussed in this book in their daily work, so he has a direct commercial interest in its subject; the book uses no data from these two companies or their clients as evidence and does not promote their services.
References
Fan, Y. (2026). Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels: From Thompson Sampling Bandits and Absorbing Markov Chains to BG/NBD Customer Lifetime Value, Read Beside the Strategic Dispositions of the Sunzi [算法营销、多触点沙普利归因与获客漏斗的随机控制] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23836264 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).