关于「平均停留时长的盲区:截尾与乘积极限」,《直播间留存的生存分析》给出的定量结论是什么?
结论:第一章说明截尾让平均停留偏低:示意直播间里把下播当离开得 408.1 秒,只算已离开者得 278.0 秒,乘积极限估计的限定平均停留是 337.9 秒。
数据口径:书中的直播间、观众数、风险参数、钩子效果与节目单均为示意;全部计算由书中程序生成;本书是非个人化经营建议,钩子只能是真实的内容或写明真实库存与真实截止时刻的福利,不用会重置的倒计时,不诱导未成年人消费,平台规则以官方公示为准。 第一章说明截尾让平均停留偏低:示意直播间里把下播当离开得 408.1 秒,只算已离开者得 278.0 秒,乘积极限估计的限定平均停留是 337.9 秒。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 278.0, 337.9, 408.1
| viewers 3000 | censored 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) |
| 3 | 0.753 | 0.753 |
| 5 | 0.668 | 0.668 |
| 10 | 0.576 | 0.576 |
| 20 | 0.521 | 0.521 |
| 30 | 0.505 | 0.505 |
| 60 | 0.479 | 0.479 |
| 300 | 0.345 | 0.345 |
| 600 | 0.254 | 0.254 |
| 1200 | 0.155 | 0.158 |
| 1800 | 0.102 | 0.105 |
核心公式
\[\hat S(t) = \prod_{t_i \le t} \left(1 - \frac{d_i}{n_i}\right).\]
查看完整验算程序
# 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)))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《直播间留存卡普兰迈耶生存曲线、划走风险尖峰定位与福利钩子插入秒数母典》第 1 章「平均停留时长的盲区:截尾与乘积极限」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 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}
}