What does The Arithmetic of Sleep conclude, in numbers, about “Sleep Architecture as a Markov Chain, and What One Night Can Tell You”?
Answer: Chapter 3's non-homogeneous Markov chain, with one decaying pressure and one ultradian timer, reproduces 0.69 of deep sleep in the first third of the night and a cycle of about 92 minutes; for a sleeper whose physiology never changes, deep sleep ranges from 24.0 to 131.0 minutes across the middle 90 % of nights, and detecting a real 10-minute change needs 165 nights per block.
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: 10, 131.0, 165, 24.0, 90
| N3 (deep) mean | 75.5 min sd 32.4 min middle 90 % 24.0 to 131.0 min |
| REM mean 100.3 min sd 38.7 min middle 90 % | 44.5 to 169.5 min |
| Nights per block needed to detect a true 10-minute change in N3 | 165 |
| Share of single nights whose N3 is 10 or more minutes below this | |
| sleeper's own mean | 0.404 |
| Reading: with nothing at all changed, a sizeable share of nights look 'worse | |
| by ten minutes of deep sleep'. One night's number is mostly the dice. |
Show the full program
# Chapter 3. How much does one night tell you? The same sleeper, with exactly
# the same physiology every night (the p05 chain, unchanged), still produces
# different nights, because stage sequences are random. We count minutes of N3
# ("deep sleep") and of REM per night over 2,000 nights, then ask how many
# nights of averaging are needed to detect a real change of 10 minutes of N3
# (two-sided alpha 0.05, power 0.80, comparing a block of nights before with a
# block after).
import math
import random
W, N1, N2, N3, R = range(5)
def step(st, t, since_rem, rng):
s = math.exp(-t / 2.5)
u = rng.random()
if st == W:
return N1 if u < 0.045 else W
if st == N1:
if u < 0.10:
return N2
return W if u < 0.12 else N1
if st == N2:
p_n3 = 0.05 * s
p_r = 0.0 if since_rem < 100 else 0.03 * (0.5 + t / 8)
if u < p_n3:
return N3
if u < p_n3 + p_r:
return R
if u < p_n3 + p_r + 0.006:
return N1
if u < p_n3 + p_r + 0.009:
return W
return N2
if st == N3:
p_out = 0.012 + 0.05 * (1 - s)
if u < p_out:
return N2
return W if u < p_out + 0.001 else N3
p_end = 1.0 / (20 + 50 * t / 8)
if u < p_end * 0.8:
return N2
if u < p_end:
return W
return R
def night(rng):
st, since, n3, rem = W, 0, 0, 0
for e in range(960):
st = step(st, e / 120.0, since, rng)
since = 0 if st == R else since + 1
n3 += st == N3
rem += st == R
return n3 / 2, rem / 2
if __name__ == "__main__":
rng = random.Random(57006)
data = [night(rng) for _ in range(2000)]
for k, name in ((0, "N3 (deep)"), (1, "REM")):
v = sorted(d[k] for d in data)
m = sum(v) / len(v)
sd = math.sqrt(sum((x - m) ** 2 for x in v) / (len(v) - 1))
print(
"{:<10} mean {:5.1f} min sd {:4.1f} min middle 90 % {:5.1f} to"
" {:5.1f} min".format(name, m, sd, v[100], v[1899])
)
sd = math.sqrt(
sum((d[0] - sum(x[0] for x in data) / 2000) ** 2 for d in data) / 1999
)
n = math.ceil(2 * (1.959964 + 0.841621) ** 2 * sd ** 2 / 10.0 ** 2)
print(
"\nNights per block needed to detect a true 10-minute change in"
" N3: {}".format(n)
)
print(
"Share of single nights whose N3 is 10 or more minutes below this"
"\nsleeper's own mean: {:.3f}".format(
sum(d[0] <= sum(x[0] for x in data) / 2000 - 10 for d in data)
/ 2000
)
)
print(
"\nReading: with nothing at all changed, a sizeable share of nights"
" look 'worse"
)
print(
"by ten minutes of deep sleep'. One night's number is mostly the"
" dice."
)Single source and citation
Fan, Y. (2026). Two-Process Sleep Architecture, Slow-Wave Glymphatic Clearance and Thermoregulatory Phase Control (Version 1.0.0), Chapter 3: Sleep Architecture as a Markov Chain, and What One Night Can Tell You. 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 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
- Chapter 8 · A Four-Step Check and a Pre-Registered Trial