This models a real prescription digital therapeutic for chronic insomnia (CBT-I delivered as software, e.g. Somryst — the first FDA-cleared prescription DTx). The engine underneath is the two-process model of sleep regulation (Borbély):
Process S (homeostatic pressure), during wake:
S(t) = 1 − (1 − S0)·e^(−t/τw), τw ≈ 18 h
During sleep, S discharges:
S(t) = S0·e^(−t/τs), τs ≈ 4.2 h
Sleep onset latency (SOL) falls as pressure at bedtime rises:
SOL = SOLmin + k·(1 − S_bed)
Sleep efficiency: SE = TST / TIB × 100%
Each simulated night, prior wake time builds sleep pressure; that pressure sets both how fast the patient falls asleep and how much total sleep time (TST) the restricted time-in-bed (TIB) window can hold, with random night-to-night noise layered on top. This is exactly the quantity a CBT-I app measures from a sleep diary or wearable.
After every 7-night week, the app's real titration rule fires — the same logic used in clinical sleep-restriction therapy:
- SE ≥ 90% — sleep is efficient, so TIB is increased by the titration step (more time allowed in bed).
- SE ≤ 80% — sleep is fragmented, so TIB is decreased by the titration step (further restriction to rebuild sleep drive).
- 80% < SE < 90% — TIB is held steady for another week.
Over several weeks this closed loop converges TIB toward the patient's true physiological sleep need while keeping efficiency high — the core mechanism regulators evaluate for clinical-endpoint clearance. This 2D view plots exactly the same closed loop as a night-by-night bar chart: each bar is one night, its height is that night's total sleep time (TST), its color is that night's efficiency tier, and the dashed line above the bars is the prescribed TIB ceiling — drag to pan through the history and scroll to zoom in on any stretch of nights.