关于「纯标准库拟合:网格搜索、高斯—牛顿、筛选偏差与外推误差」,《习惯渐近曲线与二十一天神话》给出的定量结论是什么?

结论:第三章用网格搜索与高斯—牛顿迭代从零写出拟合器,并说明真实 T95 为 250 天时,外推区间宽达真值的 2.16 倍。

数据口径:书中的人群参数、遗忘速率与线索指数均为示意;全部计算由书中程序生成;本书不是医疗或心理建议,也不是个人化的经营建议。 书中以标注框区分已发表的证据、可运行的 Python 计算(19 段程序)、原典与作者的假说。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 2.16, 250, 95

true T95p10p50p90band / truthshare > 2x truth
3026.630.235.00.280.000
6657.265.976.40.290.000
12095.6121.9159.70.530.005
250140.7239.1681.92.160.140
查看完整验算程序
# Chapter 3. p33: How sure is a T95 that lies beyond the 84 observed days?
# For true T95 of 30, 66, 120 and 250 days we simulate 200 participants
# each (plateau 35, start 5, noise sd 3, scores rounded to 0-42, seeded;
# illustrative), fit by grid plus linear least squares (p31), and print
# the 10th, 50th and 90th percentiles of the fitted T95 and the width of
# that 80 % band relative to the truth.
import math
import random
from statistics import quantiles

TS = list(range(1, 85))
GRID = [0.001 * 1.04 ** i for i in range(160)]


def ls_given_c(ts, ys, c):
    xs = [math.exp(-c * t) for t in ts]
    n = len(xs)
    mx, my = math.fsum(xs) / n, math.fsum(ys) / n
    sxx = math.fsum((x - mx) ** 2 for x in xs)
    sxy = math.fsum((x - mx) * (y - my) for x, y in zip(xs, ys))
    s = sxy / sxx
    a = my - s * mx
    sse = math.fsum((y - a - s * x) ** 2 for x, y in zip(xs, ys))
    return sse, a, -s


rng = random.Random(20261112)
print("true T95   p10     p50     p90    band / truth   share > 2x truth")
for true_t in (30.0, 66.0, 120.0, 250.0):
    c = math.log(20 * 30 / 35) / true_t
    fits = []
    for _ in range(200):
        ys = [min(42, max(0, round(35 - 30 * math.exp(-c * t)
                                   + rng.gauss(0, 3)))) for t in TS]
        s, a, b, g = min(ls_given_c(TS, ys, g) + (g,) for g in GRID)
        fits.append(math.log(20 * b / a) / g if 20 * b > a else 0.0)
    q = quantiles(fits, n=10)
    over = len([f for f in fits if f > 2 * true_t]) / len(fits)
    print("%8.0f  %6.1f  %6.1f  %6.1f   %12.2f   %16.3f"
          % (true_t, q[0], q[4], q[8], (q[8] - q[0]) / true_t, over))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《习惯形成渐近曲线、二十一天神话证伪与情境线索自动化指数母典》第 3 章「纯标准库拟合:网格搜索、高斯—牛顿、筛选偏差与外推误差」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 5DL-B-197 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026197,
  author    = {Fan, Yafu},
  title     = {Asymptotic Habit-Formation Curves, Debunking the 21-Day Myth and a Cue-Based Automaticity Index},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

本书其他章节结论