Methodology
How Pennie calculates your balance.
Last updated: April 22, 2026
Nightpenny is built on a pair of well-studied ideas from sleep science. Nothing we do is novel medicine — it's well-known math rendered as a piggy bank. This page documents the math so you can trust the numbers.
The daily delta
Each night, Pennie takes the time you actually slept (from Apple Health) and subtracts your target sleep hours. The result is the night's delta:
- Positive delta = a deposit.
- Negative delta = a withdrawal.
- Zero = a flat night.
Your target defaults to 8 hours and you can change it in Settings.
The rolling balance
The headline balance is the sum of the last 14 deltas. We chose 14 nights because of Van Dongen et al. 2003 — the classic sleep-debt study showing that cognitive impairment from sleep loss accumulates over roughly two weeks, with no meaningful recovery until the window turns over. (See Sources below.)
Older nights fall off the window as newer ones enter. One catastrophic night's impact fades; chronic debt remains visible.
Why the first hour of a deposit counts more
Sleep science is clear that catching up from a big deficit is not a one-to-one deal — you recover most of the benefit in the first extra hour, and diminishing returns after. So the app lightly discounts deposits beyond the first hour. You still bank them, but not at full value.
The discount is deliberately gentle so the gauge still feels responsive when you go to bed early. The goal is an honest signal, not a punishing one.
Why the balance clamps at −8 hours
Without a floor, one brutal week would drown the gauge for a month. Van Dongen's data suggests cognitive-debt effects plateau at roughly a week of chronic restriction, so we cap the visible debt at −8 hours — about one full night's worth. Your actual unknown “true” debt may be larger; the number on the gauge stays readable.
Two-process sleep regulation (Borbély)
The circadian component of the app — the typical-dip heatmap — is built on Borbély's two-process model. The afternoon dip you feel around 8 hours after wake is the trough in process C (the circadian alerting signal) meeting rising process S (homeostatic sleep pressure from time awake). We visualise that intersection as a pattern you've had historically — never as a prediction of what you will feel.
What the heatmap is (and isn't)
The 7-day × 24-hour heatmap in the Forecast tab is derived from the circadian model plus the weekdays that have historically been worse for you. Cells are tinted by a likelihood score combining:
- The circadian post-lunch dip (Gaussian peak ~8h after wake).
- A pre-bed wind-down drop (Gaussian peak ~2.5h before bedtime).
- A weekday penalty — if your Thursdays average negative, your Thursday afternoons are shaded darker.
- A global multiplier scaled to how deep your current debt is.
Every cell is a pattern from your history. It's never a confidence percentage and never a “you will crash” claim. Language that hedges this — “typically,” “historically for you” — is a deliberate constraint of the copy.
What we explicitly don't do
- We don't diagnose. The app cannot detect sleep apnea, insomnia, restless leg syndrome, or any condition. If you have concerns, please see a healthcare provider.
- We don't treat. Nudges in the app are suggestions you can dismiss. There's no protocol, no clinical recommendation.
- We don't predict. “Typical” is not “guaranteed.” A bad Thursday next week is a possibility, not a plan.
Sources
- Borbély AA. A two-process model of sleep regulation. Human Neurobiology, 1982.
- Van Dongen HPA, Maislin G, Mullington JM, Dinges DF. The cumulative cost of additional wakefulness: dose-response effects on neurobehavioral functions and sleep physiology from chronic sleep restriction and total sleep deprivation. Sleep, 2003; 26(2):117–126.
- CDC / NIOSH. Long Work Hours, Extended or Irregular Shifts, and Worker Fatigue.
- National Sleep Foundation. Sleep Debt: The Hidden Cost of Insufficient Rest.
The app's source code for the calculator is readable in the project's public git repository — see SleepDebtBank/Core/Domain/SleepDebtCalculator.swift.