What does The Arithmetic of Sleep conclude, in numbers, about “A Four-Step Check and a Pre-Registered Trial”?
Answer: Chapter 8 gives a four-step check and a pre-registered crossover trial (score visible against hidden, 75 completers). Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's hypotheses; apart from cited literature, all data in the book are synthetic.
Scope of the numbers: It is not medical advice, gives no doses and recommends no product; for persistent insomnia the first-line treatment is cognitive behavioural therapy for insomnia. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's hypotheses; apart from cited literature, all data in the book are synthetic.
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: 75
| Completers needed (normal approximation) | 75 |
| Recruit, allowing 20 % dropout | 94 |
| Simulated power with 75 completers and a true effect of 1.5 | 0.900 |
Show the full program
# Chapter 8. Sample size for the pre-registered crossover: each participant
# spends three weeks with the nightly sleep score VISIBLE and three weeks with
# it HIDDEN (the device still records), in random order, one week apart.
# Primary outcome: Insomnia Severity Index (ISI, 0-28) at the end of each
# period. Primary estimate: mean of (visible - hidden); POSITIVE means worse
# with the score visible. Smallest effect of interest 1.5 ISI points; assumed
# sd of the within-person difference 4.0; two-sided alpha 0.05, power 0.90; 20
# % dropout. The formula is checked by simulating the trial.
import math
import random
def z(p):
lo, hi = -10.0, 10.0
for _ in range(100):
mid = 0.5 * (lo + hi)
if 0.5 * (1 + math.erf(mid / math.sqrt(2))) < p:
lo = mid
else:
hi = mid
return 0.5 * (lo + hi)
def t_crit(df):
# two-sided 0.05 critical value of Student's t by numerical integration of
# the density
def dens(x):
return (
math.exp(math.lgamma((df + 1) / 2) - math.lgamma(df / 2))
/ math.sqrt(df * math.pi)
* (1 + x * x / df) ** (-(df + 1) / 2)
)
lo, hi = 0.0, 10.0
for _ in range(60):
mid = 0.5 * (lo + hi)
n, h = 2000, mid / 2000
area = sum(dens((i + 0.5) * h) for i in range(n)) * h
if 0.5 + area < 0.975:
lo = mid
else:
hi = mid
return 0.5 * (lo + hi)
if __name__ == "__main__":
sesoi, sd = 1.5, 4.0
n = math.ceil((z(0.975) + z(0.90)) ** 2 * sd ** 2 / sesoi ** 2)
print("Completers needed (normal approximation): {}".format(n))
print("Recruit, allowing 20 % dropout: {}".format(math.ceil(n / 0.8)))
rng = random.Random(57015)
tc = t_crit(n - 1)
hits = 0
for _ in range(4000):
d = [rng.gauss(sesoi, sd) for _ in range(n)]
m = sum(d) / n
s = math.sqrt(sum((x - m) ** 2 for x in d) / (n - 1))
hits += abs(m / (s / math.sqrt(n))) > tc
print(
"Simulated power with {} completers and a true effect of 1.5: {:.3f}"
.format(n, hits / 4000)
)Single source and citation
Fan, Y. (2026). Two-Process Sleep Architecture, Slow-Wave Glymphatic Clearance and Thermoregulatory Phase Control (Version 1.0.0), Chapter 8: A Four-Step Check and a Pre-Registered Trial. 5D Library. https://doi.org/10.5281/zenodo.24090162
DOI: 10.5281/zenodo.24090162 · Read the monograph · 5DL-B-057 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026057,
author = {Fan, Yafu},
title = {Two-Process Sleep Architecture, Slow-Wave Glymphatic Clearance and Thermoregulatory Phase Control},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
doi = {10.5281/zenodo.24090162},
url = {https://doi.org/10.5281/zenodo.24090162}
}Other chapter answers in this book
- Chapter 1 · Sleep Pressure, the Clock, and What Caffeine Actually Does
- Chapter 2 · The Sleep Switch: Why Ageing Fragments the Night Before It Shortens It
- Chapter 3 · Sleep Architecture as a Markov Chain, and What One Night Can Tell You
- Chapter 4 · Does Sleep Wash the Brain? Diffusion, Flow and an Open Dispute
- Chapter 5 · Warm Hands, Cool Core: the Thermal Gate of Sleep
- Chapter 6 · What a Sleep Tracker Can Know, and the Score That Keeps You Awake
- Chapter 7 · The Defensive Qi by Day and by Night: the *Lingshu* and the Sleeping Immortal