What does Survival Analysis for Livestream Retention conclude, in numbers, about “From Retention to Hazard: the Nelson-Aalen Estimator and the Entry Spike”?
Answer: Chapter 2 locates the entry spike with the Nelson-Aalen estimator, the hazard in the first two seconds being 133.3 times that of settled viewers, and shows how casually marked spikes produce false reports.
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: 133.3
| Nelson-Aalen H(t): 5s 0.386 | 10s 0.532 | 30s 0.663 | 60s 0.716 | 600s 1.350 |
| hazard after 600 s in the room: 0.00074 per s | ||||
| bin (s) | exits | viewer-s | hazard/s | ratio |
| 0-2 | 560 | 5678 | 0.09863 | 133.3 |
| 2-4 | 329 | 4700 | 0.07000 | 94.6 |
| 4-6 | 201 | 4116 | 0.04883 | 66.0 |
| 6-10 | 182 | 7322 | 0.02486 | 33.6 |
| 10-20 | 164 | 16312 | 0.01005 | 13.6 |
| 20-30 | 48 | 15363 | 0.00312 | 4.2 |
| 30-60 | 79 | 44223 | 0.00179 | 2.4 |
| 60-120 | 108 | 82912 | 0.00130 | 1.8 |
| 120-300 | 294 | 208247 | 0.00141 | 1.9 |
| 300-600 | 262 | 257110 | 0.00102 | 1.4 |
| peak bin 0-2 s is 133 times the settled hazard |
Key formula
Show the full program
# Chapter 2. p21: Nelson-Aalen cumulative hazard and binned swipe hazard.
# Same illustrative room R as p11 (same seed). On the viewer's own clock
# (seconds since entry) it computes the Nelson-Aalen estimate
# H(t) = sum over exit times of d/n, the hazard per bin as exits divided
# by viewer-seconds at risk, and the ratio of each bin to the hazard
# measured after the first ten minutes in the room.
import math
import random
T_END = 3600
SWITCH = [180, 900, 1260, 1980, 2700] # 环节切换秒数(示意)
SPIKE_LEN, B_SW = 30, 0.012
LAM0 = 1.0 / 600.0
A_OPEN, TAU = 0.12, 6.0
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):
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 nelson_aalen(rows):
# 每个退出秒数 t:H += d / n(n = 停留至少 t 秒的人数)
dur = sorted((d, ev) for _, d, ev in rows)
n, i, incs, out = len(dur), 0, [], []
while i < len(dur):
t = dur[i][0]
d = 0
j = i
while j < len(dur) and dur[j][0] == t:
d += dur[j][1] # step
j += 1
if d:
incs.append(d / n)
out.append((t, math.fsum(incs)))
n -= j - i # step
i = j
return out
def binned(rows, lo, hi):
# 区间 [lo, hi) 内:退出数 / 在场人秒
ev = len([1 for _, d, e in rows if e and lo < d <= hi])
expo = math.fsum(min(d, hi) - lo for _, d, _ in rows if d > lo)
return ev, expo, ev / expo
rows = simulate(20261113)
na = nelson_aalen(rows)
late = binned(rows, 600, 3600)[2]
def h_at(t):
v = 0.0
for tt, hh in na:
if tt > t:
break
v = hh
return v
print("Nelson-Aalen H(t): " + " ".join(
"%ds %.3f" % (t, h_at(t)) for t in (5, 10, 30, 60, 600)))
print("hazard after 600 s in the room: %.5f per s" % late)
print(" bin (s) exits viewer-s hazard/s ratio")
for lo, hi in ((0, 2), (2, 4), (4, 6), (6, 10), (10, 20), (20, 30),
(30, 60), (60, 120), (120, 300), (300, 600)):
ev, ex, h = binned(rows, lo, hi)
print("%4d-%-5d %8d %9.0f %10.5f %6.1f"
% (lo, hi, ev, ex, h, h / late))
first = binned(rows, 0, 2)[2]
print("peak bin 0-2 s is %.0f times the settled hazard" % (first / late))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 2: From Retention to Hazard: the Nelson-Aalen Estimator and the Entry Spike. 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
- Chapter 1 · The Blind Spot of Average Viewing Time: Censoring and the Product Limit
- Chapter 3 · Two Clocks: Seconds since Entry, the Programme Clock and Delayed Entry
- Chapter 4 · Piecewise-Constant Hazards: Maximum Likelihood, Likelihood Ratios and Finding the Switches
- Chapter 5 · A Model of What a Hook Does: the Window, the Aftermath and Who Stays
- Chapter 6 · Dynamic Programming for Hook Insertion: the Best Seconds for K Hooks
- Chapter 7 · Classical Sources East and West: Sunzi on Spirit and Graunt's Table of Mortality
- Chapter 8 · Closing the Loop: a Hazard Review after Every Show and a Plan to Falsify