5D Library › 回溯信念锁定、序贯痛点唤醒与马尔可夫升单自动机 · English

第六章 跨板块转移矩阵:估计、蚕食与异质性

一条稀有的跨板块转移要多少用户才估得准

转化链的参数不是写出来的,而是估计出来的。设用户每月在四个板块 C、A、M、B 之间移动或停止(X),其中声学到商业脚本(A 到 B)这一条转移很稀有(每月 0.01),却很值钱。转移矩阵的极大似然估计就是按行归一化的计数;它的不确定性可以用对用户重抽样的自助法估计 (Efron and Tibshirani 1993)。

推导

# Chapter 6. [p11] How many users does it take to estimate a cross-module
# transition? Monthly moves among modules C, A, M, B and X (stopped).
# The true matrix below has one rare but valuable link, A -> B (0.01).
# For panels of n users followed 12 months from module C or A (seed
# 69), the maximum-likelihood estimate (row-normalised counts) of
# A -> B and its bootstrap 90% interval (200 resamples of users).
import random

S = ("C", "A", "M", "B", "X")
P = {"C": (0.60, 0.10, 0.08, 0.02, 0.20),
     "A": (0.08, 0.62, 0.08, 0.01, 0.21),
     "M": (0.06, 0.06, 0.66, 0.02, 0.20),
     "B": (0.02, 0.02, 0.02, 0.84, 0.10)}

def step(s, rng):
    u, acc = rng.random(), 0.0
    for t, p in zip(S, P[s]):
        acc += p
        if u < acc:
            return t
    return "X"

def path(rng):
    s = rng.choice(("C", "A"))
    out = []
    for _ in range(12):
        if s == "X":
            break
        t = step(s, rng)
        out.append((s, t))
        s = t
    return out

def est(paths):
    n_a = sum(1 for p in paths for s, t in p if s == "A")
    n_ab = sum(1 for p in paths for s, t in p if s == "A" and t == "B")
    return n_ab / n_a if n_a else 0.0

if __name__ == "__main__":
    rng = random.Random(69)
    print("   users   estimate A->B   90% bootstrap interval  rel. width")
    for n in (100, 1000, 10000):
        paths = [path(rng) for _ in range(n)]
        e = est(paths)
        boots = sorted(est([paths[rng.randrange(n)] for _ in range(n)])
                       for _ in range(200))
        lo, hi = boots[10], boots[189]
        print("   {:6,d} {:13.4f}   [{:.4f}, {:.4f}] {:16.2f}".format(
            n, e, lo, hi, (hi - lo) / 0.01))
    print("   true A->B = 0.0100")
    print("\nReading: a rare cross-module link cannot be read off a few")
    print("hundred users: at 1,000 users its interval is still three")
    print("quarters as wide as the value itself.")
#    users   estimate A->B   90% bootstrap interval  rel. width
#       100        0.0050   [0.0000, 0.0142]             1.42
#     1,000        0.0101   [0.0066, 0.0140]             0.74
#    10,000        0.0099   [0.0086, 0.0110]             0.23
#    true A->B = 0.0100
#
# Reading: a rare cross-module link cannot be read off a few
# hundred users: at 1,000 users its interval is still three
# quarters as wide as the value itself.

100 位用户时,A 到 B 的估计是 0.0050,90% 自助区间从 0 到 0.0142,宽度是真值的 1.42 倍;1,000 位用户时区间宽度仍是真值的 0.74 倍;要到 10,000 位用户,宽度才降到 0.23 倍。一个只观察了几百位用户就宣布「声学用户转商业脚本的比例是百分之几」的结论,在统计上几乎没有意义。

「自己学会算」会不会蚕食测算

学堂教用户自己排盘,学成者不再购买测算。这是否得不偿失?程序把第五章的链改写为:测算用户每月以 0.04 的概率报名,报名时付学费 360;毕业生不再买测算,每月以 gg 的概率购买牌照,0.10 流失。没有学堂时,这 0.04 的用户继续买测算。

推导

# Chapter 6. [p12] "Learn to read it yourself": does the academy course
# cannibalize readings? A variant of the p09 chain, discounted at 0.99
# a month. A reader (25 a month in readings) enrols with probability
# 0.04 a month and pays the course, 360, on enrolment. Graduates
# compute their own charts and never buy a reading again; each month
# a share g of them takes the licence (12,537) and 0.10 lapse. Without
# a course, the 0.04 stay readers. Reported: a reader's discounted LTV
# with and without the course, and the break-even course fee.
ENTRY_L = 12537.0

def ltv_reader(course, g=0.01, months=900, COURSE=360.0):
    vt, vg = 0.0, 0.0
    for _ in range(months):
        if course:
            nt = 25 + 0.99 * (0.70 * vt + 0.04 * (COURSE + vg)
                              + 0.002 * ENTRY_L)
            ng = 0.99 * ((0.90 - g) * vg + g * ENTRY_L)
        else:
            nt = 25 + 0.99 * (0.74 * vt + 0.002 * ENTRY_L)
            ng = 0.0
        vt, vg = nt, ng
    return vt

if __name__ == "__main__":
    a = ltv_reader(False)
    print("   reader LTV without a course: {:8.2f}".format(a))
    for g in (0.0, 0.002, 0.005, 0.01, 0.02):
        print("   with the course, g = {:.3f}: {:8.2f}".format(
            g, ltv_reader(True, g)))
    for g in (0.0, 0.005):
        lo, hi = 0.0, 360.0
        for _ in range(50):
            mid = (lo + hi) / 2
            if ltv_reader(True, g, COURSE=mid) > a:
                hi = mid
            else:
                lo = mid
        if hi < 0.01:
            print("   at g = {:.3f} the course pays even if it is free"
                  .format(g))
        else:
            print("   break-even course fee at g = {:.3f}: {:.2f}".format(
                g, hi))
    print("\nReading: a graduate's lost readings are worth less than the")
    print("fee, because a reader's remaining reading spend is short-lived;")
    print("the fear of cannibalization matters only for a cheap course.")
#    reader LTV without a course:   186.32
#    with the course, g = 0.000:   208.73
#    with the course, g = 0.002:   237.58
#    with the course, g = 0.005:   278.98
#    with the course, g = 0.010:   343.38
#    with the course, g = 0.020:   457.33
#    break-even course fee at g = 0.000: 186.32
#    at g = 0.005 the course pays even if it is free
#
# Reading: a graduate's lost readings are worth less than the
# fee, because a reader's remaining reading spend is short-lived;
# the fear of cannibalization matters only for a cheap course.

没有学堂时,测算用户的 LTV 是 186.32;有学堂、毕业生从不买牌照(g=0g = 0)时为 208.73,仍然更高;g=0.005g = 0.005 时为 278.98。学费在 g=0g = 0 时的盈亏平衡点是 186.32;只要有千分之五的毕业生每月购买牌照,学堂即使免费也划算。原因是一位测算用户剩下的测算消费本来就不长久:「自己学会算」所蚕食的,只是一笔不大的、很快就会消失的收入。

一条链装不下两种人

第五章用一条链描述全部测算用户。程序设两类用户:20% 是投入型(每月留存 0.85、报名 0.08),80% 是随意型(留存 0.50、报名 0.01)。分析者把 24 个月内观察到的全部移动合在一起,拟合一条链。这正是经典的「移动者—停留者」问题 (Blumen et al. 1955)。

推导

# Chapter 6. [p13] One Markov chain for two kinds of reader (mover-
# stayer). 20% of readers are "engaged": monthly stay 0.85, to course
# 0.08, lapse 0.07; 80% are "casual": stay 0.50, to course 0.01, lapse
# 0.49. An analyst pools 24 months of observed moves (20,000 readers,
# seed 69) and fits one chain by maximum likelihood. Compared: the
# share of new readers who ever enrol, true versus predicted by the
# pooled chain, and the share still reading after 1 to 24 months.
import random

TYPES = ((0.2, 0.85, 0.08), (0.8, 0.50, 0.01))   # share, stay, course

def ever_enrol(stay, course):
    return course / (1 - stay)

if __name__ == "__main__":
    rng = random.Random(69)
    n_stay = n_course = n_from = 0
    for _ in range(20000):
        share = rng.random()
        stay, course = (TYPES[0][1:] if share < TYPES[0][0]
                        else TYPES[1][1:])
        for _ in range(24):
            n_from += 1
            u = rng.random()
            if u < stay:
                n_stay += 1
            elif u < stay + course:
                n_course += 1
                break
            else:
                break
    ps, pc = n_stay / n_from, n_course / n_from
    true = sum(w * ever_enrol(s, c) for w, s, c in TYPES)
    pooled = ever_enrol(ps, pc)
    print("   pooled chain: stay {:.4f}, to course {:.4f}".format(ps, pc))
    print("   share of new readers who ever enrol: true {:.4f},"
          " pooled chain {:.4f}".format(true, pooled))
    print("   share still reading   month:   1       3       6      12"
          "      24")
    tr = [sum(w * s ** m for w, s, c in TYPES) for m in (1, 3, 6, 12, 24)]
    print("     true                  " + " ".join(
        "{:7.4f}".format(x) for x in tr))
    print("     pooled chain          " + " ".join(
        "{:7.4f}".format(ps ** m) for m in (1, 3, 6, 12, 24)))
    print("\nReading: the pooled chain gets total conversion about right")
    print("but the shape of survival wrong: too many readers kept early,")
    print("far too few in the long tail, where the engaged readers who")
    print("later buy the course and the licence are.")
#    pooled chain: stay 0.6603, to course 0.0420
#    share of new readers who ever enrol: true 0.1227, pooled chain 0.1236
#    share still reading   month:   1       3       6      12      24
#      true                   0.5700  0.2228  0.0879  0.0286  0.0040
#      pooled chain           0.6603  0.2879  0.0829  0.0069  0.0000
#
# Reading: the pooled chain gets total conversion about right
# but the shape of survival wrong: too many readers kept early,
# far too few in the long tail, where the engaged readers who
# later buy the course and the licence are.
真实的两类混合与单一链给出的留存曲线(对数刻度)。

合并后的链给出的总报名比例(0.1236)与真实值(0.1227)几乎相同,但留存曲线的形状完全不对:第 1 个月高估(0.6603 对 0.5700),第 12 个月却只有真实值的四分之一左右(0.0069 对 0.0286)。长尾中留下的恰恰是投入型用户,也就是日后买课程、买牌照的人。用单一链预测长期转化,会系统地低估这部分人。

假说 · 尚未验证

作者的诠释(尚未验证): 测算业务的用户至少可以分成「投入型」与「随意型」两类,转化分析应当先分群再建链。什么会证明这一判断错:若用真实数据拟合的两类混合模型,在留存曲线上并不比单一链明显更好(例如按似然比检验或交叉验证的预测误差),那么两类的区分在这一业务中并不存在。

小结

稀有的跨板块转移要上万位用户才估得准。「自己学会算」所蚕食的测算收入,在本书参数下小于学费,更小于牌照之路的价值。把两类用户合成一条链,会在总转化上看似正确,却在长尾留存上严重失真。

参考文献

Blumen, Isadore, Marvin Kogan, and Philip J. McCarthy. 1955. The Industrial Mobility of Labor as a Probability Process. Cornell Studies in Industrial and Labor Relations 6. Cornell University.
Efron, Bradley, and Robert J. Tibshirani. 1993. An Introduction to the Bootstrap. Chapman & Hall.

Fan, Y. (2026). Retrodictive Belief Locking, Sequential Pain-Point Agitation and Markovian Upsell Automata: Bayesian Trust Avalanches, Sunk-Cost Commitment Ratchets and Cross-Domain Transition Matrices [回溯信念锁定、序贯痛点唤醒与马尔可夫升单自动机] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090186 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).