What does Survival Analysis for Livestream Retention conclude, in numbers, about “Dynamic Programming for Hook Insertion: the Best Seconds for K Hooks”?
Answer: Chapter 6 schedules three hooks by dynamic programming for a gain of 1970.2, against 257.9 on average for one hook every 20 minutes; if the run sheet slips a minute and the hooks stay put, the gain falls to 210.7; scheduling is only 1.29 times as good with no spikes and 9.53 times with very tall ones.
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: 1970.2, 20, 257.9
| no hook | 15493.7 audience-minutes per 1000 settled viewers |
| K | 1 DP starts 180 gain 1061.4 (re-evaluated 1061.4) |
| K | 2 DP starts 180,900 gain 1588.5 (re-evaluated 1588.5) |
| K | 3 DP starts 180,900,1260 gain 1970.2 (re-evaluated 1970.2) |
| K | 1 brute force over all 360 starts: 180 s, gain 1061.4 |
| K | 3 uniform every 20 min, 120 phases: mean 257.9 min 79.0 max 1130.1 |
| K | 3 on the quarter hours 900,1800,2700: gain 579.5 |
| K | 3 reacting after 3 switches 930,2010,2730: gain 118.9 |
Key formula
Show the full program
# Chapter 6. p61: dynamic programming for K hooks.
# Programme clock in 10-second bins (360 bins). Hazard per bin from the
# two M1 levels of p41 (rest 0.00072, switch windows 0.0069 per s).
# A hook lasts W = 6 bins at hazard x (1 - rho), rho = 0.5; then for
# E = 3 bins it returns pi = 0.3 of the hazard it removed; two hook
# starts must be at least G = 18 bins (3 min) apart. Objective: audience
# seconds of a closed group of 1000 settled viewers. Because survival
# multiplies, V(t) = area(t) + exp(-x_t) * V(t + 1) is an exact Bellman
# recursion; the state is (bin, hooks used, bins since last start).
import math
T_END, BIN = 3600, 10
NB = T_END // BIN
SWITCH = [180, 900, 1260, 1980, 2700] # 环节切换秒数(示意)
SPIKE_LEN = 30
REST, SPIKE = 0.00072, 0.0069
W, E, G, RHO, PI = 6, 3, 18, 0.5, 0.3 # 钩子参数(示意)
CAP = max(G, W + E)
def bin_hazard():
sec = [REST] * T_END
for s in SWITCH:
for t in range(s, s + SPIKE_LEN):
sec[t] = SPIKE
return [math.fsum(sec[b * BIN:(b + 1) * BIN]) for b in range(NB)]
HB = bin_hazard()
HWIN = [math.fsum(HB[a:min(a + W, NB)]) for a in range(NB)]
def haz(t, c):
# c = 距上一次钩子开始的箱数(CAP 表示很久以前或从未)
if c < W:
return HB[t] * (1.0 - RHO)
if c < W + E:
return HB[t] + PI * RHO * HWIN[t - c] / E
return HB[t]
def step(x):
return BIN * (1.0 - math.exp(-x)) / x, math.exp(-x)
def dp(k_max):
nxt = {(k, c): 0.0 for k in range(k_max + 1) for c in range(CAP + 1)}
pol = []
for t in range(NB - 1, -1, -1):
cur, choice = {}, {}
for k in range(k_max + 1):
for c in range(CAP + 1):
opts = [(c, k, False)]
if c >= G and k < k_max:
opts.append((0, k + 1, True))
best = None
for ct, kk, start in opts:
a, g = step(haz(t, ct))
v = a + g * nxt[(kk, min(ct + 1, CAP))]
if best is None or v > best[0]:
best = (v, start)
cur[(k, c)], choice[(k, c)] = best
pol.append(choice)
nxt = cur
pol.reverse()
k, c, starts = 0, CAP, []
for t in range(NB):
if pol[t][(k, c)]:
starts.append(t * BIN)
k, c = k + 1, 0
c = min(c + 1, CAP)
return nxt[(0, CAP)], starts
def forward(starts):
sb = [s // BIN for s in starts]
parts, surv, c = [], 1.0, CAP
for t in range(NB):
c = 0 if t in sb else min(c + 1, CAP) if t else CAP
a, g = step(haz(t, c))
parts.append(surv * a)
surv *= g
return math.fsum(parts)
def gain(starts):
return 1000.0 * (forward(starts) - forward([])) / 60.0
base = 1000.0 * forward([]) / 60.0
print("no hook: %.1f audience-minutes per 1000 settled viewers" % base)
for k in (1, 2, 3):
v, starts = dp(k)
print("K=%d DP starts %-18s gain %6.1f (re-evaluated %6.1f)"
% (k, ",".join("%d" % s for s in starts),
1000.0 * (v - forward([])) / 60.0, gain(starts)))
brute = max((gain([a * BIN]), a * BIN) for a in range(NB))
print("K=1 brute force over all 360 starts: %d s, gain %.1f"
% (brute[1], brute[0]))
uni = [gain([ph, ph + 1200, ph + 2400]) for ph in range(0, 1200, BIN)]
print("K=3 uniform every 20 min, 120 phases: mean %.1f min %.1f max %.1f"
% (math.fsum(uni) / len(uni), min(uni), max(uni)))
print("K=3 on the quarter hours 900,1800,2700: gain %.1f"
% gain([900, 1800, 2700]))
print("K=3 reacting after 3 switches 930,2010,2730: gain %.1f"
% gain([930, 2010, 2730]))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 6: Dynamic Programming for Hook Insertion: the Best Seconds for K Hooks. 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 2 · From Retention to Hazard: the Nelson-Aalen Estimator and the Entry Spike
- 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 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