What does Habit Curves and the 21-Day Myth conclude, in numbers, about “A Standard-Library Fitter: Grid Search, Gauss-Newton, Screening Bias and Extrapolation Error”?

Answer: Chapter 3 writes a fitter from scratch with grid search and Gauss-Newton iteration and shows that when the true T95 is 250 days, the extrapolation band is 2.16 times as wide as the truth.

Scope of the numbers: Its population parameters, forgetting rates and cue indices are illustrative; all calculations are generated by its programs; it is not medical or psychological advice, nor personalised business advice. 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: 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
Show the full program
# 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))

Single source and citation

Fan, Y. (2026). Asymptotic Habit-Formation Curves, Debunking the 21-Day Myth and a Cue-Based Automaticity Index (Version 1.0.0), Chapter 3: A Standard-Library Fitter: Grid Search, Gauss-Newton, Screening Bias and Extrapolation Error. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 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}
}

Other chapter answers in this book