Reduce sleep deficit over time
Sleep deficit shouldn't be calculated as simple difference between "ideal time" and "actual time". It should exponentially reduce over time, so most recents nights make more effect on current sleep deficit.
For example, let's imagine that my ideal sleep period is 8 hours. But I had a hard week, so on weekdays I slept 6 hours. On Tuesday I had 2 hours deficit calculated, on Wednesday 4 hours and so on... To fullfill that deficit for me it would be enough to sleep ~10 hours (2 hours extra on each day) on weekends. I wouldn't feel any lack of sleep, I would be totally refreshed, but graph of total sleep deficit with current logic would show me 6 hours (=2+2+2+2+2-2-2). It's frustrating, because ideal sleep and smart badtime notification rely on sleep deficit and they can't work.
I suggest to add exponential decay for sleep deficit with some given weight coefficient λ (you could put it in settings). There are several formulas you could use for that, I'd suggest simple discrete formula:
DEFICIT(today) = (IDEAL_TIME - SLEEP_TIME(today)) + DEFICIT(yesterday) / λ
Let's take λ=1.4 and recalculate my example
on Tuesday DEFICIT(monday) = 0, so DEFICIT(tuesday) = (8 - 6) + 0 / 3 = 2
DEFICIT(wednesday) = (8 - 6) + DEFICIT(tuesday) / 1.4 = 3.43
DEFICIT(thursday) = 4.45
DEFICIT(friday) = 5.18
DEFICIT(saturday) = 5.70
(slept 10 hours on saturday)
DEFICIT(sunday) = (8 - 10) + DEFICIT(saturday) / 1.4 = 2.07
(slept 10 hours on sunday)
DEFICIT(monday) = (8 - 10) + DEFICIT(sunday) / 1.4 = -0.52
Current sleep deficit intents to accumulate errors, and only a way to use it is reset sleep deficit every week.
With exponential decay sleep deficit is more stable and intents to recover if a person sleeps well. Also it gives more "real-life-related" information and builds better graphs.
We’re migrating our feature requests to http://forum.urbandroid.org.
Thank you everyone for supporting this feature request here!
Kibber Shuriq commented
Alternatively, simple linear coefficients could be used for "older" deficits. E.g., if I slept 2 hours less than ideal two weeks ago, it would only add 2/14th of an hour to cumulative deficit today (assuming 2 weeks deficit accumulation period).