We are currently using Fitbit API to integrate our users' Fitbit data into our system. Currently, we are developing a sleep efficiency tracker. As part of that, we need to understand how Fitbit is calculating the sleep efficiency score.
I have searched far and wide but all I have found are speculative posts on the Fitbit Community forums, with no actual confirmation about the formula used, or any official articles which clearly state how the sleep efficiency score is calculated.
The most likely candidates I found were the following two formulas. But can anyone point me to some official documentation that discusses this? Or can someone from the Fitbit team please confirm/deny if this is how the sleep efficiency score is calculated? I would assume this is basic information which should be understood by our developers in order to properly integrate that score into our system.
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Hello. Could you provide an overall indication of how sleep efficiency is calculated without sharing the formula? I know it's generally time asleep divided by time in bed. But I'm trying to get a sense of whether the time it takes to initially fall asleep is considered part of the denominator or if it's excluded altogether.
Best AnswerI just did some research on my exports (which date back to 2014) and confirmed that the old Sleep Efficiency score that used to be included in the export can be calculated as follows, per other values that are still included in the export:
Efficency % = minutesAsleep / (minutesAsleep + minutesAwake)
To match the old "score" exactly, multiple the above by 100 and round to the nearest integer. Personally, I find that I get more useful data by rounding to one decimal place since the values all cluster so tightly on a day-to-day basis.
This website gives you some detail, but Fitbit won't release the actual algorithm.
Alternatively, if you have Excel or any standard statistical package (SAS, STATA, R, Python), you could simply run a regression analysis to get an approximation of the coefficients that they use (i.e., the formula). It's most likely a linear regression, something like Score = B0 + B1(time asleep) + B2(time light sleep) + B3(time deep sleep) + B4(time REM sleep) + B5(time awake). They could also have used percentages for all of the above and included on more term for total minutes asleep (or total minutes asleep + awake).
Best AnswerThat is fine. But why don't expose the score to the devs? I would really like to understand this decision. Thanks!
Best Answer