5D Library › Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games · 中文
Chapter 4. The Stopping Time of Separation and the “Danger Window”
A lock can be broken
The locking of Chapters 2 and 3 is deterministic: once locked, locked for ever. Real rhythms are pushed by countless small disturbances — illness, travel, family matters — so the phase difference jitters around the locked point and is occasionally pushed over a barrier, slipping a whole turn. That moment is called a phase slip. In the sense of the analogy, it corresponds to one break of a locked relationship. This chapter asks two things: how that moment is distributed in time, and whether it bunches in some particular “window”.
Calculation
The noisy Adler equation and its barrier. The drift is minus the gradient of the tilted periodic potential . The locked point lies at the bottom of a well, and the barrier towards the next well has height Write . Kramers’ formula gives the mean waiting time for as (Kramers 1940); the mean first-passage time of one-dimensional diffusion also has an exact double integral (Hänggi et al. 1990).
The seventh program computes the mean time to the first slip in three ways: Kramers’ approximation, the exact integral and 300 random simulations.
Calculation
# Chapter 4. How long a locked pair stays locked when life is noisy.
# dphi = (dw - K sin phi) dt + sigma dW (K = kAB + kBA)
# The locked phase sits in a well of the tilted potential
# V(phi) = -dw phi - K cos phi,
# at phi* = asin(dw / K); the barrier towards the next well has height
# dV = 2 K cos(phi*) - dw (pi - 2 phi*).
# A "slip" is the first time phi reaches phi* + 2 pi. Three estimates of
# the mean time to the first slip, with D = sigma^2 / 2:
# Kramers 2 pi / (K cos phi*) * exp(dV / D) (valid for dV >> D)
# integral the exact mean first-passage time of 1-D diffusion,
# T = (1/D) int dy exp(V(y)/D) int_{-inf}^{y} exp(-V(z)/D) dz
# simulated Euler-Maruyama, step 0.01, 300 runs
# K = 1, dw = 0.5, in model time units.
import math
import random
K, DW = 1.0, 0.5
PHI = math.asin(DW / K)
DV = 2 * K * math.cos(PHI) - DW * (math.pi - 2 * PHI)
def V(x):
return -DW * x - K * math.cos(x)
def integral_T(d, n=1500):
# (lower limit truncated at PHI - 2*pi, where exp(-V/D) is negligible)
lo, hi = PHI - 2 * math.pi, PHI + 2 * math.pi
h = (hi - lo) / n
xs = [lo + i * h for i in range(n + 1)]
inner, acc, total = 0.0, [], 0.0
for x in xs:
inner += math.exp(-V(x) / d) * h
acc.append(inner)
for x, a in zip(xs, acc):
if x >= PHI:
total += math.exp(V(x) / d) * a * h
return total / d
def simulate(d, runs, rng, dt=0.01):
s = math.sqrt(2 * d * dt)
times = []
for _ in range(runs):
x, t = PHI, 0.0
while x < PHI + 2 * math.pi:
x += (DW - K * math.sin(x)) * dt + s * rng.gauss(0, 1)
t += dt
times.append(t)
return times
if __name__ == "__main__":
rng = random.Random(62007)
print(" barrier dV = {:.4f}".format(DV))
print(" dV/D Kramers integral simulated CV alive at mean")
for ratio in (2.0, 3.0, 4.0):
d = DV / ratio
kr = 2 * math.pi / (K * math.cos(PHI)) * math.exp(ratio)
ts = simulate(d, 300, rng)
m = sum(ts) / len(ts)
sd = (sum((t - m) ** 2 for t in ts) / (len(ts) - 1)) ** 0.5
alive = sum(t > m for t in ts) / len(ts)
print(" {:3.1f} {:7.1f} {:8.1f} {:9.1f} {:4.2f} {:5.3f}"
.format(ratio, kr, integral_T(d), m, sd / m, alive))
print("\nReading: the simulated mean agrees with the exact integral")
print("within sampling error (300 runs: about 6 %). Kramers' formula is")
print("the large-barrier limit and approaches both as dV/D grows. The")
print("waiting time is close to exponential (coefficient of variation")
print("near 1, about 1/e still locked at the mean): a constant hazard.")
print("Noise alone gives no special 'danger window'.")
# barrier dV = 0.6849
# dV/D Kramers integral simulated CV alive at mean
# 2.0 53.6 65.3 66.1 0.92 0.363
# 3.0 145.7 168.7 160.8 0.95 0.387
# 4.0 396.1 441.0 469.4 0.98 0.367
#
# Reading: the simulated mean agrees with the exact integral
# within sampling error (300 runs: about 6 %). Kramers' formula is
# the large-barrier limit and approaches both as dV/D grows. The
# waiting time is close to exponential (coefficient of variation
# near 1, about 1/e still locked at the mean): a constant hazard.
# Noise alone gives no special 'danger window'.The simulated mean agrees with the exact integral within sampling error; Kramers’ formula is the large-barrier limit, and as rises from 2.0 to 4.0 it draws closer to the exact value (53.6 against 65.3 at first, 396.1 against 441.0 at the end). The mean waiting time grows exponentially with : each extra of barrier multiplies the wait by about .
More important are the last two columns. The coefficient of variation of the waiting time is close to 1 (0.92 to 0.98), and the share still locked at the mean time is close to (0.363, 0.387, 0.367) — the signature of an exponential distribution. An exponential distribution has a constant hazard: how long a pair has been locked has no bearing on whether it slips next. With noise alone there is no especially dangerous window in time.
Adding a yearly shock
Notions such as the “flowing year” assume a different mechanism: a shock from outside at a fixed moment each year. The eighth program adds such a shock to the same system — at the start of every year the phase is pushed towards the barrier by — and records when in the year each slip happens.
Calculation
# Chapter 4. A yearly shock on top of the noise.
# Same locked pair as p07 (K = 1, dw = 0.5, dV/D = 3, mean first slip about
# 165 time units). Let one "year" be 20 time units. At the start of every
# year the phase receives a kick of size A towards the barrier (an outside
# event of fixed size, at a fixed date). For 400 runs each, the program
# records the date of the first slip - the last time phi crossed the top
# of the barrier, pi - phi*, before going on to phi* + 2 pi - and reports
# the mean waiting time in years, the share of slips in the first twelfth
# of a year after a kick (1/12 = 0.083 if the date did not matter), and
# the hazard in that month relative to the rest of the year.
import math
import random
K, DW = 1.0, 0.5
PHI = math.asin(DW / K)
DV = 2 * K * math.cos(PHI) - DW * (math.pi - 2 * PHI)
YEAR, DT = 20.0, 0.01
def first_slip(a, d, rng):
s = math.sqrt(2 * d * DT)
steps_per_year = int(round(YEAR / DT))
top = math.pi - PHI
x, i, crossed = PHI, 0, 0.0
while True:
if a and i % steps_per_year == 0 and i > 0:
x += a
prev = x
x += (DW - K * math.sin(x)) * DT + s * rng.gauss(0, 1)
i += 1
if prev < top <= x:
crossed = i * DT
if x >= PHI + 2 * math.pi:
return crossed
if __name__ == "__main__":
d = DV / 3.0
rng = random.Random(62008)
print(" kick A mean wait (years) share in month after kick"
" hazard ratio")
for a in (0.0, 0.5, 1.0, 1.5):
ts = [first_slip(a, d, rng) for _ in range(400)]
mean_y = sum(ts) / len(ts) / YEAR
frac = [(t / YEAR) % 1.0 for t in ts]
early = sum(f < 1 / 12 for f in frac) / len(ts)
ratio = (early / (1 / 12)) / ((1 - early) / (11 / 12))
print(" {:3.1f} {:6.2f} {:5.3f}"
" {:5.2f}".format(a, mean_y, early, ratio))
print("\nReading: without kicks the date of a slip is spread evenly over")
print("the year. A kick both shortens the wait and concentrates slips")
print("in the month that follows it. The window is a property of the")
print("assumed kick: the model puts it there, it does not discover it.")
# kick A mean wait (years) share in month after kick hazard ratio
# 0.0 7.82 0.090 1.09
# 0.5 6.32 0.177 2.37
# 1.0 4.05 0.323 5.24
# 1.5 2.35 0.505 11.22
#
# Reading: without kicks the date of a slip is spread evenly over
# the year. A kick both shortens the wait and concentrates slips
# in the month that follows it. The window is a property of the
# assumed kick: the model puts it there, it does not discover it.Without shocks () the slips are spread evenly over the year: the share falling in the first month after the shock date is 0.090, close to , a hazard ratio of 1.09. The stronger the shock, the shorter the mean wait (from 7.82 years to 2.35) and the more the slips bunch in the month after it: at that month holds 0.323, a hazard ratio of 5.24; at it holds 0.505, a hazard ratio of 11.22.
This result has to be read correctly. The window exists because the model assumes a shock of fixed size on a fixed date; the model put the window there and did not discover it. To say that a real “yearly” window exists, one must first see it in data.
How much data a window takes to test
The ninth program computes how many separations with exact dates it takes to see a hazard ratio in a month named in advance, and then shows what happens when the month is chosen afterwards.
Calculation
# Chapter 4. How many break-ups it takes to see a danger window.
# Claim to test: "slips are h times as likely in a pre-named month as in
# the rest of the year". Under no effect a slip falls in the named month
# with probability 1/12; under the claim with p1 = h / (h + 11). With n
# dated events the test counts those in the window and rejects at
# one-sided alpha = 0.05 (exact binomial). The program finds the smallest
# n with 80 % power, and the number of couples to follow for five years if
# 25 % of them separate in that time. It then shows what happens when the
# window is chosen AFTER looking: with no effect at all, picking the
# busiest of 12 months and testing it at 0.05 (20,000 simulated studies).
import math
import random
def tail(n, p, k):
"""P(X >= k) for X ~ Binomial(n, p)."""
return sum(math.comb(n, j) * p ** j * (1 - p) ** (n - j)
for j in range(k, n + 1))
def crit(n, p0=1 / 12, alpha=0.05):
k = 0
while tail(n, p0, k) > alpha:
k += 1
return k
def n_needed(h, power=0.8):
p1 = h / (h + 11)
n = 10
while tail(n, p1, crit(n)) < power:
n += 1
return n
if __name__ == "__main__":
print(" hazard ratio h events needed couples followed 5 years")
for h in (1.5, 2.0, 3.0, 5.0):
n = n_needed(h)
print(" {:3.1f} {:5d} {:6,d}".format(
h, n, math.ceil(n / 0.25)))
rng = random.Random(62009)
n, hits = 120, 0
k = crit(n)
for _ in range(20000):
counts = [0] * 12
for _ in range(n):
counts[rng.randrange(12)] += 1
hits += max(counts) >= k
print("\n no effect, 120 events, busiest month tested at 0.05:")
print(" false-positive rate {:.3f}".format(hits / 20000))
print("\nReading: a hazard ratio of 2 in a named month needs about 130")
print("dated separations; a ratio of 1.5 needs over 400, from more than")
print("1,600 couples. Choosing the month after seeing the data turns a")
print("5 % test into one that 'finds' a window in over 40 % of studies.")
# hazard ratio h events needed couples followed 5 years
# 1.5 409 1,636
# 2.0 130 520
# 3.0 47 188
# 5.0 17 68
#
# no effect, 120 events, busiest month tested at 0.05:
# false-positive rate 0.432
#
# Reading: a hazard ratio of 2 in a named month needs about 130
# dated separations; a ratio of 1.5 needs over 400, from more than
# 1,600 couples. Choosing the month after seeing the data turns a
# 5 % test into one that 'finds' a window in over 40 % of studies.At a hazard ratio of 5, 17 dated separations suffice; at 2, 130 are needed; at 1.5, 409 — which, if a quarter of couples part within five years, means following 1,636 couples. The second half shows the commoner mistake: in data with no effect at all, looking at the dates of 120 separations, picking the busiest month and then testing it makes a 5 % test “find” a window in 0.432 of studies.
Note
What this means for a “high-risk window for a break-up” feature. A system that claims to predict the month of a break-up needs at least three things before it can be tested: a window rule written down in advance (not fixed after seeing outcomes), each person’s exact date of separation, and enough of them — several hundred separations for a moderate effect. Without these, any example that “came true” cannot be told apart from the coincidences in the second half of the ninth program.
Hypothesis · not established
The author’s hypothesis (not established): tested on separation data with exact dates, any yearly-window rule published in advance shows a hazard ratio in the window month indistinguishable from 1. What would show it to be wrong: in a pre-registered test run by an independent analyst, a hazard ratio in the window month significantly above 1 in two independent samples.
Summary
In a noisy locked system the wait until the first slip is close to exponential and the hazard is constant: noise itself makes no danger window. A window appears only when the model assumes an outside shock on a fixed date, and the stronger the shock the sharper it is, the hazard ratio rising from 1.09 to 11.22 — but this is a consequence of an assumption, not a discovery. To test a window in real data the month must be named in advance and many separations with exact dates collected; choosing the month afterwards makes a 5 % test “find” a window that does not exist in 0.432 of studies.
References
Fan, Y. (2026). Dyadic Phase Coupling, Bilinear Compatibility Tensors and Spatiotemporal Grid Games: Asymmetric Kuramoto Locking, Stopping-Time Separation Hazards and Magic-Square Permutation Operators [双人相位耦合、双线性相容张量与时空网格博弈] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24090172 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).