Methodology

How Pennie calculates your balance.

Last updated: May 24, 2026

Nightpenny is built on a pair of well-studied ideas from sleep science. Nothing here is novel medicine. It's known math rendered as a piggy bank. This page documents the math — the actual formula, the cited sources, and the deliberate simplifications — 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.

Worked example: target 8h, slept 6h 30m → delta of −1h 30m. Target 8h, slept 9h 15m → delta of +1h 15m. 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, a 14-night chronic sleep-restriction study in which 48 healthy adults were assigned to 4, 6, or 8 hours time-in-bed for two weeks. Cognitive performance on the Psychomotor Vigilance Task, working memory, and cognitive throughput all degraded linearly across the 14 days in the restricted groups, with no plateau and no apparent adaptation. The paper's sharpest finding is what gives Nightpenny its honest tone:

“Subjective sleepiness ratings showed an acute response to sleep restriction but only small further increases after the first day, suggesting that subjective ratings may underestimate the actual impact of chronic sleep restriction on waking neurobehavioral functions.”

— Van Dongen et al., Sleep, 2003

Translation: people stop feeling the debt after a few days. Their cognition keeps degrading. Nightpenny's balance is an objective accountant for the gap between what you feel and what your body is carrying.

Mechanically: older nights fall off the window as newer ones enter. One catastrophic night's impact fades after two weeks; chronic debt remains visible until habits change.

Why the first hour of a deposit counts more

Catching up from a deficit isn't one-to-one. Most recovery happens in the first extra hour of a long night, with diminishing returns after that. Pennie applies a small, explicit discount to deposits above one hour:

adjustedDelta(delta) =
  delta                                if delta ≤ 0
  delta                                if 0 < delta ≤ 1 hour
  1 hour + (delta − 1 hour) × 0.6      if delta > 1 hour

Worked examples (assuming an 8-hour target):

  • Slept 7h → delta −1h → counted as −1h (face value)
  • Slept 9h → delta +1h → counted as +1h (first hour, full value)
  • Slept 10h → delta +2h → counted as +1h 36m (1h + 1h × 0.6)
  • Slept 11h → delta +3h → counted as +2h 12m (1h + 2h × 0.6)

Withdrawals are taken at face value — debt accumulates linearly in the literature, recovery does not. The discount is deliberately gentle so the gauge stays 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 shows performance deficits accumulating linearly over two weeks of restriction, but the gauge needs to stay readable. So visible debt is capped at −8 hours, about one full night's worth, with the rest carried implicitly. Your true debt may be larger; the number on the gauge stays human-sized.

This is the only place Nightpenny deliberately lies to you, and it lies in your favour: a debt of fifteen hours and a debt of eight both show as “−8h”. The repayment plan still recommends multiple recovery nights when the underlying debt is deeper, even if the gauge reads the same.

Two-process sleep regulation (Borbély)

The circadian component of the app — the typical-dip heatmap — is built on Borbély's 1982 two-process model, reappraised and updated by Borbély, Daan, Wirz-Justice and Deboer in 2016. The model proposes that wake/sleep is regulated by two independent processes:

  • Process S — homeostatic sleep pressure. Rises during wakefulness, dissipates during sleep. The longer you've been awake, the higher it climbs.
  • Process C — circadian alerting signal. Oscillates roughly over 24 hours, independent of prior sleep/wake history. The post-lunch dip you feel around eight hours after waking is the trough of Process C.

Their interaction explains the daily shape of alertness: morning sharpness (low S, rising C), the afternoon dip (S still rising, C in its trough), the second wind (S still rising, C climbing back), and the crash before bed (S maxed out, C falling). The Forecast heatmap visualises 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 across the last 28 nights, your Thursday afternoons shade 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.

The 7-night trend signal

Alongside the balance, Pennie classifies the last seven nights as repaying, accruing, or steady:

  • Repaying — ≥3 deposit nights in the last 7, with more deposits than withdrawals.
  • Accruing — ≥3 withdrawal nights in the last 7, with more withdrawals than deposits.
  • Steady — anything in between.

The trend is a directional read, not a magnitude. A −4h balance with a “repaying” trend tells a different story than a −4h balance with an “accruing” one, even when the headline number is identical.

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.
  • We don't replace evidence-based therapy. If insomnia is the underlying problem, the gold-standard treatment is CBT-I (cognitive-behavioural therapy for insomnia). Nightpenny is a balance sheet, not a clinician.

References

  • Borbély AA. A two-process model of sleep regulation. Human Neurobiology, 1982; 1(3):195–204. PMID: 7185792.
  • Borbély AA, Daan S, Wirz-Justice A, Deboer T. The two-process model of sleep regulation: a reappraisal. Journal of Sleep Research, 2016; 25(2):131–143. DOI: 10.1111/jsr.12371.
  • 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. DOI: 10.1093/sleep/26.2.117.
  • CDC / NIOSH. Long Work Hours, Extended or Irregular Shifts, and Worker Fatigue. Background context for the 72-hour shift-work mode.
  • National Sleep Foundation. Sleep Debt: The Hidden Cost of Insufficient Rest. Background context on the asymmetric debt-vs-recovery dynamic.

The app's source code for the calculator is readable in the project's public git repository. The function shown above lives at SleepDebtBank/Core/Domain/SleepDebtCalculator.swift (see adjustedDelta, lines 183–189). If the page disagrees with the code, the code is the truth and this page is a bug.