What does Koopman Modes for Audience Turning Points conclude, in numbers, about “East and West in the Sources: "Knowing the Incipient" in the Book of Changes and Fourier's Analysis of Heat”?
Answer: Chapter 7 examines "knowing the incipient" in the Book of Changes (ten minutes before the turn the second difference has a signal-to-noise ratio of only 0.031) and Fourier's analysis of heat (a fixed Fourier basis holds only 0.603 of the energy of a decaying swing).
Scope of the numbers: Marked boxes separate published evidence, runnable Python calculations (19 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: 0.031
| minute 22, ten minutes before the turn (noise sd 40) | |
| k difference noise sd signal / noise | |
| 1 | 23.897 56.57 0.422 |
| 2 | -3.012 97.98 0.031 |
| 3 | 0.177 178.89 0.001 |
| fit ends at t* + offset share with turn found within 5 min | |
| -10 minutes | 0.050 |
| -5 minutes | 0.235 |
| +0 minutes | 0.560 |
| +5 minutes | 0.850 |
Show the full program
# Chapter 7. p71: "the subtle beginning of movement", measured.
# Part 1: on the illustrative p11 slow part, the first, second and third
# differences ten minutes before the turn, against white noise (sd 40):
# the k-th difference multiplies the noise variance by C(2k, k), so the
# finer the sign, the deeper it is buried. Part 2: across 200 random
# sessions (p51 generator, fixed seed), how often a rank-5 DMD fitted on
# the last 40 minutes puts the turn within 5 minutes of the truth, when
# the fit ends 10 or 5 minutes before the turn, at it, or 5 after.
import math
import cmath
import random
def slow(t):
# 慢分量:进场与离场两个指数之差(示意参数,单位:人)
return 800.0 + 5000.0 * (math.exp(-t / 60.0) - math.exp(-t / 20.0))
def cycle(t):
# 每 12 分钟一轮上新或福袋带来的起伏(示意)
return 150.0 * math.cos(2.0 * math.pi * t / 12.0)
def session(sd=40.0, n=120, shift=0):
rng = random.Random(20261113 + shift)
return [slow(t) + cycle(t) + rng.gauss(0.0, sd) for t in range(n)]
def random_session(rng, sd=None, n=90):
# 随机示意场次:进场、离场时间常数,福袋周期与噪声都在示意区间内抽取
t1, t2 = rng.uniform(45.0, 90.0), rng.uniform(12.0, 25.0)
amp, base = rng.uniform(3000.0, 6000.0), rng.uniform(500.0, 1200.0)
per, cyc = rng.uniform(10.0, 15.0), rng.uniform(80.0, 200.0)
ph = rng.uniform(0.0, 2.0 * math.pi)
noise = rng.uniform(20.0, 60.0) if sd is None else sd
x = [base + amp * (math.exp(-t / t1) - math.exp(-t / t2))
+ cyc * math.cos(2.0 * math.pi * t / per + ph)
+ rng.gauss(0.0, noise) for t in range(n)]
tstar = math.log(t1 / t2) / (1.0 / t2 - 1.0 / t1)
return x, tstar
def dot(a, b):
return math.fsum(x * y for x, y in zip(a, b))
def matmul(a, b):
bt = list(zip(*b))
return [[dot(r, c) for c in bt] for r in a]
def transpose(a):
return [list(r) for r in zip(*a)]
def svd(a):
# 单边 Jacobi(Hestenes):两两旋转列直到正交,A = U S V^T
m, n = len(a), len(a[0])
if n > m:
u, s, v = svd(transpose(a))
return v, s, u
cols = [[a[i][j] for i in range(m)] for j in range(n)]
vc = [[1.0 if i == j else 0.0 for i in range(n)] for j in range(n)]
for sweep in range(60):
rotated = False
for p in range(n - 1):
for q in range(p + 1, n):
al = dot(cols[p], cols[p])
be = dot(cols[q], cols[q])
ga = dot(cols[p], cols[q])
if ga == 0.0 or abs(ga) <= 1e-15 * math.sqrt(al * be):
continue
rotated = True
ze = (be - al) / (2.0 * ga)
t = math.copysign(1.0, ze) / (
abs(ze) + math.sqrt(1.0 + ze * ze))
c = 1.0 / math.sqrt(1.0 + t * t)
s = c * t
cp, cq = cols[p], cols[q]
cols[p] = [c * x - s * y for x, y in zip(cp, cq)]
cols[q] = [s * x + c * y for x, y in zip(cp, cq)]
vp, vq = vc[p], vc[q]
vc[p] = [c * x - s * y for x, y in zip(vp, vq)]
vc[q] = [s * x + c * y for x, y in zip(vp, vq)]
if not rotated:
break
sig = [math.sqrt(dot(c_, c_)) for c_ in cols]
order = sorted(range(n), key=lambda j: (-sig[j], j))
s = [sig[j] for j in order]
u = [[cols[j][i] / sig[j] if sig[j] > 0.0 else 0.0 for j in order]
for i in range(m)]
v = [[vc[j][i] for j in order] for i in range(n)]
return u, s, v
def hankel(x, rows):
# 延迟嵌入:第 i 行是从第 i 分钟起的一段序列
k = len(x) - rows + 1
return [[x[i + j] for j in range(k)] for i in range(rows)]
def dmd(x, rows, r):
# Hankel 上的精确 DMD:X、Y 为错开一列的两块,A~ = U^T Y V S^-1
h = hankel(x, rows)
xs = [row[:-1] for row in h]
ys = [row[1:] for row in h]
u, s, v = svd(xs)
ur = [row[:r] for row in u]
vr = [row[:r] for row in v]
at = matmul(matmul(transpose(ur), ys), vr)
at = [[at[i][j] / s[j] for j in range(r)] for i in range(r)]
return ur, at, s, h
def charpoly(a):
# Faddeev-LeVerrier:特征多项式 z^n + c1 z^(n-1) + c2 z^(n-2) 直到 cn
n = len(a)
m = [[0.0] * n for _ in range(n)]
coef = [1.0]
for k in range(1, n + 1):
m = matmul(a, m)
for i in range(n):
m[i][i] += coef[-1]
am = matmul(a, m)
coef.append(-math.fsum(am[i][i] for i in range(n)) / k)
return coef
def roots(coef):
# Durand-Kerner 同时迭代求全部复根(cmath)
n = len(coef) - 1
z = [cmath.rect(0.9, 0.4 + 2.0 * math.pi * k / n) for k in range(n)]
def p(x):
r = complex(1.0, 0.0)
for c in coef[1:]:
r = r * x + c
return r
for _ in range(800):
new = []
for i in range(n):
den = complex(1.0, 0.0)
for j in range(n):
if j != i:
den *= z[i] - z[j]
new.append(z[i] - p(z[i]) / den)
moved = max(abs(a - b) for a, b in zip(new, z))
z = new
if moved < 1e-14:
break
return z
def eigvals(a):
z = roots(charpoly(a))
z = [complex(w.real, 0.0) if abs(w.imag) < 1e-12 else w for w in z]
return sorted(z, key=lambda w: (-round(abs(w), 9), w.imag))
def csum(zs):
zs = list(zs)
return complex(math.fsum(z.real for z in zs),
math.fsum(z.imag for z in zs))
def csolve(a, b):
# 复数高斯消元(部分主元)
n = len(a)
m = [list(a[i]) + [b[i]] for i in range(n)]
for c in range(n):
p = max(range(c, n), key=lambda i: abs(m[i][c]))
m[c], m[p] = m[p], m[c]
for i in range(c + 1, n):
f = m[i][c] / m[c][c]
for j in range(c, n + 1):
m[i][j] -= f * m[c][j]
xs = [0j] * n
for i in range(n - 1, -1, -1):
acc = csum(m[i][j] * xs[j] for j in range(i + 1, n))
xs[i] = (m[i][n] - acc) / m[i][i]
return xs
def amplitudes(x, lam):
# 最小二乘求振幅:x_t = sum_k b_k lam_k^t(t 从窗口起点数)
n = len(lam)
vt = [[w ** t for w in lam] for t in range(len(x))]
g = [[csum(vt[t][i].conjugate() * vt[t][j] for t in range(len(x)))
for j in range(n)] for i in range(n)]
rhs = [csum(vt[t][i].conjugate() * x[t] for t in range(len(x)))
for i in range(n)]
return csolve(g, rhs)
def slow_part(w, rows, r, min_period=30.0):
# 拟合模态,只留周期长于 min_period 分钟、|lambda| > 0.6 的慢模态
ur, at, s, h = dmd(w, rows, r)
lam = eigvals(at)
b = amplitudes(w, lam)
keep = [k for k in range(len(lam)) if abs(lam[k]) > 0.6
and abs(cmath.phase(lam[k])) < 2.0 * math.pi / min_period]
return [(lam[k], b[k]) for k in keep]
def slow_value(modes, t):
return csum(b * lam ** t for lam, b in modes).real
def predicted_peak(w, rows, r, ahead, grid=0.05):
# 慢分量在 [0, len(w) + ahead] 上的最高点,返回相对窗口末端的分钟数
modes = slow_part(w, rows, r)
best, arg = None, 0.0
steps = int(round((len(w) - 1 + ahead) / grid))
for i in range(steps + 1):
t = i * grid
val = slow_value(modes, t)
if best is None or val > best:
best, arg = val, t
return arg - (len(w) - 1), best, modes
tstar = 30.0 * math.log(3.0)
t0 = int(tstar) - 10
vals = [slow(t0 + k) for k in range(4)]
d1 = vals[1] - vals[0]
d2 = vals[2] - 2.0 * vals[1] + vals[0]
d3 = vals[3] - 3.0 * vals[2] + 3.0 * vals[1] - vals[0]
print("minute %d, ten minutes before the turn (noise sd 40)" % t0)
print(" k difference noise sd signal / noise")
for k, d in ((1, d1), (2, d2), (3, d3)):
sd = 40.0 * math.sqrt(math.comb(2 * k, k))
print(" %d %10.3f %8.2f %14.3f" % (k, d, sd, abs(d) / sd))
rng = random.Random(20261117)
hits = {-10: 0, -5: 0, 0: 0, 5: 0}
for _ in range(200):
x, ts = random_session(rng)
for off in hits:
end = int(round(ts)) + off
w = x[max(0, end - 40):end]
d, level, modes = predicted_peak(w, len(w) // 2, 5, 30)
if abs(end - 1 + d - ts) <= 5.0:
hits[off] += 1
print("fit ends at t* + offset share with turn found within 5 min")
for off in sorted(hits):
print(" %+4d minutes %.3f" % (off, hits[off] / 200.0))Single source and citation
Fan, Y. (2026). Koopman Operators and Dynamic Mode Decomposition: Linearising Nonlinear Cash-Flow Swings and Forecasting Turning Points in Livestream Audience Curves (Version 1.0.0), Chapter 7: East and West in the Sources: "Knowing the Incipient" in the Book of Changes and Fourier's Analysis of Heat. 5D Library. DOI pending
DOI pending · monograph page goes live after publication · 5DL-B-238 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026238,
author = {Fan, Yafu},
title = {Koopman Operators and Dynamic Mode Decomposition: Linearising Nonlinear Cash-Flow Swings and Forecasting Turning Points in Livestream Audience Curves},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}Other chapter answers in this book
- Chapter 1 · Two or Three Modes: the Low-Rank Structure of a Livestream Audience Curve and the Built-In Lag of Moving Averages
- Chapter 2 · The Koopman Operator: Lifting Nonlinear Dynamics into Linear Ones, and the Limits of the Lift
- Chapter 3 · Jacobi Rotations: Symmetric Eigendecomposition and the Singular Value Decomposition with the Standard Library Alone
- Chapter 4 · Dynamic Mode Decomposition: Eigenvalues, Amplitudes and the False Decay Caused by Noise
- Chapter 5 · Lead Time at the Turning Point: a Mode-Based Warning Every Five Minutes against Moving Averages
- Chapter 6 · Cash Flow: Linearising Daily, Weekly and Monthly Swings with Modes, and Choosing the Observable
- Chapter 8 · Closing the Empirical Loop: a Mode Fit Every Five Minutes, a Cooling Warning and a Pre-Registered Test