What does Survival Analysis for Livestream Retention conclude, in numbers, about “The Blind Spot of Average Viewing Time: Censoring and the Product Limit”?

Answer: Chapter 1 shows that censoring biases the average downwards: counting the end of the stream as leaving gives 408.1 seconds, counting only leavers gives 278.0, and the restricted mean from the product-limit estimator is 337.9.

Scope of the numbers: Its rooms, audiences, hazard parameters, hook effects and run sheets are illustrative; all calculations are generated by its programs; the book is not individual business advice. Marked boxes separate published evidence, runnable Python calculations (18 programs), classical sources and the author's hypotheses.

中文版

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: 278.0, 337.9, 408.1

viewers 3000censored at stream end 345
naive mean, censored counted as exits :408.1 s
mean of completed visits only:278.0 s
mean if everyone could stay on (truth):778.6 s
restricted mean to 1200 s KM 337.9 truth 338.5
KM median stay 36 s
t (s)KM S(t)truth S(t)
30.7530.753
50.6680.668
100.5760.576
200.5210.521
300.5050.505
600.4790.479
3000.3450.345
6000.2540.254
12000.1550.158
18000.1020.105

Key formula

\[\hat S(t) = \prod_{t_i \le t} \left(1 - \frac{d_i}{n_i}\right).\]
Show the full program
# Chapter 1. p11: average dwell time versus the Kaplan-Meier curve.
# Room R (illustrative, not platform data): a 60-minute stream, 400
# follower arrivals in the first minute and 2600 feed arrivals spread
# over the first 55 minutes. Hazard of leaving, per second, for a viewer
# with frailty z: z * (base + opening term + switch spike), where the
# opening term A*exp(-u/tau) runs on the viewer's own clock u (seconds
# since entry) and the switch spikes run on the programme clock.
# Viewers still in the room at 3600 s are censored. The "truth" column
# lets the same viewers run on past the end with the base hazard only.
import math
import random

T_END = 3600
SWITCH = [180, 900, 1260, 1980, 2700]   # 环节切换秒数(示意)
SPIKE_LEN, B_SW = 30, 0.012              # 切换尖峰:30 秒、每秒 0.012
LAM0 = 1.0 / 600.0                       # 基础划走风险(每秒)
A_OPEN, TAU = 0.12, 6.0                  # 入场尖峰:A*exp(-u/tau)
SHAPE = 2.0                              # 个体差异:伽马分布形状参数


def prog_hazard(horizon):
    h = [LAM0] * horizon
    for s in SWITCH:
        for t in range(s, s + SPIKE_LEN):
            h[t] = LAM0 + B_SW
    return h


def open_int(u):
    # 入场尖峰在 [u, u+1) 秒内的积分
    return A_OPEN * TAU * (math.exp(-u / TAU) - math.exp(-(u + 1) / TAU))


def simulate(seed, horizon=T_END):
    rng = random.Random()
    rng.seed(seed)
    ent = [rng.randrange(0, 60) for _ in range(400)]
    ent += [rng.randrange(0, 3300) for _ in range(2600)]
    ent.sort()
    ph = prog_hazard(horizon)
    rows = []
    for e in ent:
        z = rng.gammavariate(SHAPE, 1.0 / SHAPE)
        need = rng.expovariate(1.0)
        cum, t = 0.0, e
        while t < horizon:
            cum += z * (ph[t] + open_int(t - e))   # step
            t += 1
            if cum >= need:
                break
        if cum >= need:
            rows.append((e, t - e, 1))
        else:
            rows.append((e, horizon - e, 0))
    return rows


def kaplan_meier(rows):
    # 乘积极限:在每个出现退出的秒数上乘以 (1 - d/n)
    times = sorted({d for _, d, ev in rows if ev})
    dur = sorted((d, ev) for _, d, ev in rows)
    n, i, s, out = len(dur), 0, 1.0, []
    for t in times:
        while i < len(dur) and dur[i][0] < t:
            n -= 1
            i += 1
        d = 0
        j = i
        while j < len(dur) and dur[j][0] == t:
            d += dur[j][1]   # step
            j += 1
        s *= 1.0 - d / n
        out.append((t, s))
    return out


def surv_at(km, t):
    s = 1.0
    for tt, ss in km:
        if tt > t:
            break
        s = ss
    return s


def rmst(km, tau):
    # 限定平均停留:生存曲线下 [0, tau] 的面积
    pts, prev_t, prev_s = [], 0, 1.0
    for t, s in km:
        if t > tau:
            break
        pts.append((t - prev_t) * prev_s)
        prev_t, prev_s = t, s
    pts.append((tau - prev_t) * prev_s)
    return math.fsum(pts)


rows = simulate(20261113)
full = simulate(20261113, horizon=T_END + 40000)
cens = len([r for r in rows if r[2] == 0])
naive = math.fsum(d for _, d, _ in rows) / len(rows)
done = [d for _, d, ev in rows if ev]
km = kaplan_meier(rows)
km_full = kaplan_meier(full)
print("viewers %d   censored at stream end %d" % (len(rows), cens))
print("naive mean, censored counted as exits : %7.1f s" % naive)
print("mean of completed visits only         : %7.1f s"
      % (math.fsum(done) / len(done)))
print("mean if everyone could stay on (truth): %7.1f s"
      % (math.fsum(d for _, d, _ in full) / len(full)))
print("restricted mean to 1200 s  KM %6.1f   truth %6.1f"
      % (rmst(km, 1200), rmst(km_full, 1200)))
med = [t for t, s in km if s <= 0.5][0]
print("KM median stay %d s" % med)
print("   t (s)   KM S(t)   truth S(t)")
for t in (3, 5, 10, 20, 30, 60, 300, 600, 1200, 1800):
    print("%8d  %8.3f  %10.3f" % (t, surv_at(km, t), surv_at(km_full, t)))

Single source and citation

Fan, Y. (2026). Kaplan-Meier Retention Curves for Livestream Rooms: Locating Swipe-Away Hazard Spikes and Timing the Insertion of Hooks (Version 1.0.0), Chapter 1: The Blind Spot of Average Viewing Time: Censoring and the Product Limit. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-277 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026277,
  author    = {Fan, Yafu},
  title     = {Kaplan-Meier Retention Curves for Livestream Rooms: Locating Swipe-Away Hazard Spikes and Timing the Insertion of Hooks},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book