关于「对数似然、网格与黄金分割:两小时能把分支比估多准」,《评论裂变分支比》给出的定量结论是什么?
结论:第四章用小崎递推、补偿子恒等式与黄金分割求最大似然估计,示意帖的分支比 95 % 区间从 0.42 到 0.92,两小时估计的标准差约 0.186。
数据口径:书中的帖子、账号、流量、成本与评论价值均为示意参数;全部计算由书中程序生成;本书是非个人化经营建议,只讨论真实用户的评论与平台官方工具买来的曝光,不涉及任何制造评论或虚构稀缺的手段。 第四章用小崎递推、补偿子恒等式与黄金分割求最大似然估计,示意帖的分支比 95 % 区间从 0.42 到 0.92,两小时估计的标准差约 0.186。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 0.42, 0.92, 95
| free beta : mu 0.745 | n 0.682 | beta 0.178 | loglik -46.268 |
| beta=0.1 | : mu 0.808 | n 0.675 | loglik -47.032 |
| 95% profile interval for n (beta fixed): 0.42 to 0.92 | |||
| truth: mu 1.0 | n 0.6 | beta 0.1; multiplier 1/(1-n) 3.07 (CI 1.72 to 12.50) |
查看完整验算程序
# Chapter 4. p42: Golden-section maximum likelihood and a profile interval.
# Same post and log-likelihood as p41. Trick: for fixed beta, scaling mu
# and n together shows that at the optimum the compensator equals the
# count, mu T + n S = N; so mu = (N - n S) / T and only n is searched.
# Outer golden-section search over log beta (Kiefer 1953), inner over n.
# Profile interval for n at fixed beta: all n whose best log-likelihood
# (mu re-optimised) lies within 1.92 of the maximum (chi-square 1 df).
import math
import random
MU, N, BETA, T = 1.0, 0.6, 0.1, 120.0
G = (math.sqrt(5) - 1) / 2
def simulate(mu, n, beta, horizon, rng):
t, excess, times = 0.0, 0.0, []
while True:
bound = mu + excess
w = rng.expovariate(bound)
t += w
if t > horizon:
return times
excess *= math.exp(-beta * w)
if rng.random() * bound <= mu + excess:
times.append(t)
excess += n * beta
def stats(times, beta, horizon):
a, prev, out = 0.0, None, []
for t in times:
if prev is not None:
a = math.exp(-beta * (t - prev)) * (1 + a)
out.append(a)
prev = t
s = math.fsum(1 - math.exp(-beta * (horizon - t)) for t in times)
return out, s
def loglik(mu, n, beta, a_list, s, horizon):
terms = [math.log(mu + n * beta * a) for a in a_list]
return math.fsum(terms) - mu * horizon - n * s
def golden_max(f, lo, hi, iters=40):
x1, x2 = hi - G * (hi - lo), lo + G * (hi - lo)
f1, f2 = f(x1), f(x2)
for _ in range(iters):
if f1 < f2:
lo, x1, f1 = x1, x2, f2
x2 = lo + G * (hi - lo)
f2 = f(x2)
else:
hi, x2, f2 = x2, x1, f1
x1 = hi - G * (hi - lo)
f1 = f(x1)
x = (lo + hi) / 2
return x, f(x)
def fit_n(times, beta, horizon):
a_list, s = stats(times, beta, horizon)
cnt = len(times)
hi = min(0.999, cnt / s - 1e-9)
n, ll = golden_max(lambda v: loglik((cnt - v * s) / horizon, v, beta,
a_list, s, horizon), 0.0, hi)
return n, (cnt - n * s) / horizon, ll
def fit_all(times, horizon):
lb, _ = golden_max(lambda x: fit_n(times, math.exp(x), horizon)[2],
math.log(0.01), math.log(2.0), 30)
b = math.exp(lb)
n, mu, ll = fit_n(times, b, horizon)
return mu, n, b, ll
def profile_n(times, n, beta, horizon):
a_list, s = stats(times, beta, horizon)
return golden_max(lambda m: loglik(m, n, beta, a_list, s, horizon),
1e-4, 5.0)[1]
times = simulate(MU, N, BETA, T, random.Random(20261121))
mu, n, b, ll = fit_all(times, T)
print("free beta : mu %.3f n %.3f beta %.3f loglik %.3f"
% (mu, n, b, ll))
n1, mu1, ll1 = fit_n(times, BETA, T)
print("beta=0.1 : mu %.3f n %.3f loglik %.3f" % (mu1, n1, ll1))
inside = [k / 100 for k in range(0, 100)
if ll1 - profile_n(times, k / 100, BETA, T) <= 1.92]
print("95%% profile interval for n (beta fixed): %.2f to %.2f"
% (inside[0], inside[-1]))
print("truth: mu %.1f n %.1f beta %.1f; multiplier 1/(1-n) %.2f"
" (CI %.2f to %.2f)" % (MU, N, BETA, 1 / (1 - n1),
1 / (1 - inside[0]), 1 / (1 - inside[-1])))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《霍克斯自激点过程、评论裂变分支比临界值与直播跟风抢购余震半衰期母典》第 4 章「对数似然、网格与黄金分割:两小时能把分支比估多准」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-234 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026234,
author = {Fan, Yafu},
title = {Hawkes Self-Exciting Point Processes: Branching-Ratio Criticality in Comment Cascades and the Aftershock Half-Life of Livestream Herd Buying},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}