关于「谐波回归:从逐日读数估计振幅与相位」,《节气、热滞后与季节需求》给出的定量结论是什么?
结论:第四章说明「哪天最热」是一个被天气噪声主导的统计量:示意数据中单日最高温的定位误差为 16.81 天,而三年逐日数据的谐波相位误差只有 1.25 天。
数据口径:书中参数为示意;全部计算由书中程序生成;本书是非个人化经营建议,订货日期只是演示,不对任何商家承诺销量。 第四章说明「哪天最热」是一个被天气噪声主导的统计量:示意数据中单日最高温的定位误差为 16.81 天,而三年逐日数据的谐波相位误差只有 1.25 天。
对照数据表
下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 1.25, 16.81
| years | harmonic: mean | rmse | | hottest day: mean | rmse | | 7-day: rmse | ||
| 1 | 32.62 | 2.25 | | | 33.08 | 16.11 | | | 15.02 |
| 3 | 32.35 | 1.25 | | | 31.59 | 16.73 | | | 15.43 |
| 10 | 32.53 | 0.68 | | | 31.74 | 16.92 | | | 15.41 |
| 30 | 32.49 | 0.37 | | | 30.47 | 16.81 | | | 15.82 |
| true lag of the first harmonic: 32.5 days |
查看完整验算程序
# Chapter 4. p42: how many years pin down the lag?
# Same illustrative truth as p41 (mean 14.0, first harmonic 14.0 C
# peaking 32.5 days after Xiazhi, second harmonic 1.0 C, AR(1) noise
# rho 0.7, sd 3.0 C). For N years of daily data, 300 seeded replicates
# compare three estimators of "when summer peaks", in days after
# Xiazhi: the first-harmonic phase (mean, cos, sin regression, sums by
# math.fsum), the single hottest day of the last year, and the centre
# of the hottest 7-day mean in the last year. Seed 20261113.
# For scale: Stine, Huybers and Fung (2009, Nature) describe the
# seasons by this same yearly sinusoid and report that its phase over
# extratropical land moved 1.7 days earlier between 1954 and 2007.
import math
import random
YEAR = 365.2422
W = 2 * math.pi / YEAR
XIAZHI = 171.68
LAG = 32.5
RHO, SD = 0.7, 3.0
REPS = 300
def simulate(days, rng):
e = rng.gauss(0, SD)
innov = SD * math.sqrt(1 - RHO ** 2)
out = []
for d in range(days):
e = RHO * e + rng.gauss(0, innov)
out.append(math.fsum([14.0,
14.0 * math.cos(W * (d - XIAZHI - LAG)),
math.cos(2 * W * (d - 200)), e]))
return out
def phase_lag(series):
c = [math.cos(W * d) for d in range(len(series))]
s = [math.sin(W * d) for d in range(len(series))]
n = len(series)
sy, sc, ss = math.fsum(series), math.fsum(c), math.fsum(s)
scc = math.fsum(x * x for x in c)
sss = math.fsum(x * x for x in s)
scs = math.fsum(x * y for x, y in zip(c, s))
syc = math.fsum(x * y for x, y in zip(series, c))
sys_ = math.fsum(x * y for x, y in zip(series, s))
# centre, then solve the 2 x 2 system for the cos and sin weights
a11 = scc - sc * sc / n
a22 = sss - ss * ss / n
a12 = scs - sc * ss / n
b1 = syc - sy * sc / n
b2 = sys_ - sy * ss / n
det = a11 * a22 - a12 * a12
bc = (b1 * a22 - b2 * a12) / det
bs = (a11 * b2 - a12 * b1) / det
peak = (math.atan2(bs, bc) / W) % YEAR
return peak - XIAZHI
def last_year_peaks(series):
seg = series[-365:]
off = len(series) - 365
hot = max(range(len(seg)), key=lambda i: seg[i]) + off
runs = [math.fsum(seg[i - 3:i + 4]) for i in range(3, len(seg) - 3)]
c7 = 3 + max(range(len(runs)), key=lambda i: runs[i]) + off
shift = (len(series) // 365 - 1) * YEAR
return hot - XIAZHI - shift, c7 - XIAZHI - shift
def rms(xs, centre):
return math.sqrt(math.fsum((x - centre) ** 2 for x in xs) / len(xs))
if __name__ == "__main__":
rng = random.Random(20261113)
print("years harmonic: mean rmse | hottest day: mean rmse"
" | 7-day: rmse")
for years in (1, 3, 10, 30):
ph, hd, h7 = [], [], []
for _ in range(REPS):
series = simulate(int(round(years * YEAR)), rng)
ph.append(phase_lag(series))
a, b = last_year_peaks(series)
hd.append(a)
h7.append(b)
print("{:5d} {:14.2f} {:5.2f} | {:16.2f} {:5.2f} | {:11.2f}"
.format(years, math.fsum(ph) / REPS, rms(ph, LAG),
math.fsum(hd) / REPS, rms(hd, LAG), rms(h7, LAG)))
print("true lag of the first harmonic: {:.1f} days".format(LAG))唯一数据源与引用
范雅福(Fan, Y.). (2026). 《二十四节气气温滞后相位、三伏一阶热惯性与季节性消费需求预测母典》第 4 章「谐波回归:从逐日读数估计振幅与相位」(版本 1.0.0). 5D Library. DOI 待发布
DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-232 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026232,
author = {Fan, Yafu},
title = {Temperature Phase Lag across the Twenty-Four Solar Terms, First-Order Thermal Inertia behind the Dog Days and Seasonal Demand Forecasting},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
note = {DOI pending}
}